I think there is already a number of answers related to this post, but one can use this which is easy to use just like plugin and also easily readable for programmers.
Send your specific date, and get its value in string form:
You can reduce the server-side load by performing this logic client-side. View source on some Digg pages for reference. They have the server emit an epoch time value that gets processed by Javascript. This way you don't need to manage the end user's time zone. The new server-side code would be something like:
public string GetRelativeTime(DateTime timeStamp)
{
return string.Format("<script>printdate({0});</script>", timeStamp.ToFileTimeUtc());
}
You could even add a NOSCRIPT block there and just perform a ToString().
I think there is already a number of answers related to this post, but one can use this which is easy to use just like plugin and also easily readable for programmers. Send your specific date, and get its value in string form:
I would recommend computing this on the client side too. Less work for the server.
The following is the version that I use (from Zach Leatherman)
iPhone Objective-C Version
You can reduce the server-side load by performing this logic client-side. View source on some Digg pages for reference. They have the server emit an epoch time value that gets processed by Javascript. This way you don't need to manage the end user's time zone. The new server-side code would be something like:
You could even add a NOSCRIPT block there and just perform a ToString().
If you want to have an output like
"2 days, 4 hours and 12 minutes ago"
, you need a timespan:Then you can access the values you like:
etc...