I'm using the TimeAgo plugin to update the time of posts automatically. It makes time like 05-08-2014 15:02:39
to 5 minutes ago
.
The problem is, the javascript uses client's clock for time. I'm from Bangladesh, Asia. But in php the default timezone varies from server to server. I'm outputting the format 05-08-2014 15:02:39
in PHP to convert it into something like 5 mintues ago
using the TimeAgo plugin.
Because server's timezone is different, instead of showing less than a minute ago
on a recent post, it shows nn hours ago
. If the server is american, it shows 11 hours ago
, if it's indian, the time shows 30 minutes ago
. How do I fix it?
As stated on the TimeAgo project page:
Are you concerned about time zone support? Don't be. Timeago handles this too. As long as your timestamps are in ISO 8601 format and include a full time zone designator (±hhmm), everything should work out of the box regardless of the time zone that your visitors live in.
So echo the dates server side with date('c',$timestamp)
and everything should work fine.