1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

[Date] Formatting date + time zones

Discussion in 'PHP' started by WebCM, Jun 21, 2008.

  1. #1
    There is a function: http://paste.ubuntu.com/21865

    It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one problem. This function does not recognize time zones.

    How to adjust date to user's time zone? Is converting to timestamp() and then to format readable to visitors the one and only solution (e.g. strtotime() + date() OR DateTime object)? Perhaps, it's possible to solve this problem with mathematical operations (it needs more combinations). Has someone dealed with time zones?

    If I store timestamps instead of datetime, PHP would deal with time zones automatically (date() with 2nd parameter). However, it will be harder to display "Today", "Tomorrow", "Yesterday"...
     
    WebCM, Jun 21, 2008 IP