The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Detect timezone?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #36769

    So I’m using a timestamp in my database to save the time when the user posts a update. Now I’ve done some tweaks and now it returns “x hours ago” and stuff like that. My problem is that it is set to be GMT even if the user browsing is in America or Australia, it might say 5 hours ago when the user posts. Now how do I change my timezone to the one of the user browsing?


    If you have registered users than you can have them set their timezone in prefs which you can then store as an offset

    If they are anonymous posting you can use javascript to grab the timezone

    var timeZone = (new Date().gettimezoneOffset()/60)*(-1);

    and then fill a hidden field with it to grab and store with the message, you can then use that offset to adjust the message times

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.