Getting current date and time

Oct 04, 2006 18:03

Is there any way to get current date and time values is S2?
I want to make dates look something like 'today, at 12:21' or '5 minutes ago'.

Thanks everyone

Leave a comment

Comments 2

kunzite1 October 4 2006, 22:43:02 UTC
Page.time is a DateTime object that contains the time in GMT when the current page was loaded.

there are no system-supplied functions that make addition and subtraction of DateTimes easy.

Reply


mart June 11 2007, 18:55:47 UTC

This sort of thing was left out because LiveJournal doesn't know the timezone of the person viewing a given page and so it doesn't actually know what "today" is.

As kunzite1 pointed out, you can get the GMT time that the page was rendered, but there's not really any easy way to do date arithmetic to produce an "n minutes ago" readout. The Comment class has a member from which you can get the number of seconds since the associated entry was posted, but that's a special case that the system calculates for you.

Reply


Leave a comment

Up