_gray (name_is_gray) wrote in s2dev,

Getting current date and time

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
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

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.

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.