Jump to content

Timezone offset


Fmdpa

Recommended Posts

I am detecting the user's timezone offset, and it doesn't seem to be giving me the right thing.

alert(-(new Date().getTimezoneOffset()/60));

It is giving me one hour more than my actual offset. So when I transfer that value into my PHP script, it displays the time as 11:30 instead of 10:30. Does it accurately display your timezone offset? I'm going to try it again tomorrow (after DST ends) and see what it gives me. Is there a way to compensate for the DST change, besides manually setting dates?P.S. You can hop over to W3Schools tryit editor, and paste it there.

Link to comment
Share on other sites

And I wondered why does IPB have a checkbox for DST instead of detecting it automatically from my timezone... there seems to be no (standard?) JavaScript method for checking if DST applies for the user's timezone.There are some DST detection scripts out there, and there, etc., but nothing standard and 100% reliable.

Link to comment
Share on other sites

Why transfer time from an unreliable client
Wouldn't times provided by the average user be fairly accurate?So the best thing would be to display the time in GMT by default, but let registered users set their own time?
Link to comment
Share on other sites

Wouldn't times provided by the average user be fairly accurate?
If I hadn't personally seen more than a hundred PCs where the time is not syncronized, I'd guess you are right, but... people disregard their time often, and certain factors apply to it not being correct, such as low mainboard battery (this resets the clock to the time the mainboard was manufactured in chinese time), travelling abroad and adjusting the time itself instead of the timezone, or adjusting the clock based on unreliable sources (e.g. the clock on the wall).
So the best thing would be to display the time in GMT by default, but let registered users set their own time?
Yes. The time in GMT, as seen from your server, and let users set their own timezone to display times in.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...