views:

292

answers:

2

Hi folks,

I'm trying to implement a "time ago" feature, for the displaying of items on a site. As I'm caching the pages I wish to use javascript in order to render the "time ago".

Javascript knows local time and problably the Timezone of the local machine so I could play with that, but that would require to hard code the server's timezone.

Therefore I'm trying to figure out a simple way to pass a ISO 8601 timestamp, in GMT time. Is there any simple and straight forward way for doing this?


Help would be much appreciated! =)

+1  A: 

The python datetime objects has a method for outputting an ISO 8601 timestamp here.

That page also has information on timezone manipulation. The timedelta object should also be useful for you.

Zach
A: 

I wouldn't use javascript to do this personally. Yes it has their local time, but it also means that the user will then see the timestamps will change when the javascript finally renders on the page.

That is, assuming you're properly not executing your javascript until the page is loaded.

Webnet