Forum Moderators: coopster
So I wonder if there are functions in PHP which enable me to specify a rough location or time zone to get correct time, or if there's a server one can contact for that in some way.
I think this will do it for you
[martin.f2o.org...]
Tom
- use JS to get the system time on the client computer
- create a PHP session
- keep track of the user and pass the user's local time as a session variable.
Of course, this won't work if the user has JS turned off or has the time incorrectly set on his computer (for example a laptop user who is travelling or someone who just doesn't care). So it should get the correct time for at least 80% of users.
Tom
It probably is more than 80%, if I was flying a plane I wouldn't change my computer's timezone every time I cross a timezone line.
And if I did it would actually confuse me more.
/add
The DST is another problem as Windows messes it up for me, on NetBSD you have to edit the symbol table of your kernel, Linux seems to do it right.
It probably is more than 80%, if I was flying a plane I wouldn't change my computer's timezone every time I cross a timezone line.
Well, that's what I meant really (and I agree, the 80% was meant to be conservative - 10% with JS turned off and 10% traveling or simply having the wrong system time which would actually still give you about 81% total).
I also agree that most people who don't adjust to the time zone they're in (either travel or their OS doesn't auto adjust for DST) probably would just be confused by a page that showed the "correct" time for their location. However, it is true that formally the times shown would be incorrect for those folks.
Tom
Yes, but I don't see them visiting a page and adjusting it, so for them it will "always" be incorrect time zone.
Huh? How so? It will be the system time on their local machine, which is what the script author wants. So if their system time is correct and they have javascript enabled, it *will* be correct.
It should only be incorrect if (the system time is incorrect) or (they have javascript disabled and they are in a different time zone than the default for the site).
Tom
Yes, that was the sole purpose of the code.
>It should only be incorrect if (the system time is incorrect) or (they have javascript disabled and they are in a different time zone than the default for the site).
In the last comment actually I wanted to explain that it is unlikely that a person who has his machine's time zone incorrect is going to go to a page where he is supposed to enter his time zone.
person who has his machine's time zone incorrect is going to go to a page where he is supposed to enter his time zone.
Oh sure. That's certainly right, but anyone who doesn't have his system time set correctly probably won't care that the times on the pages he's viewing are incorrect too, so I think you can discount those people.
Doh! I finally realized that the script I mentioned is Martin's script! I guess he knows how it works... we're just not getting our message across to each other. Anyway, it's a good script and should do what the original poster wants pretty well.
Tom
This site has good information about the changes to DST: [timeanddate.com...] .
Yes, that's some. Most are not, they are using their local times with their own DST rules.
The scripts will get it right if the OS is set up correctly.
PS. I personally don't have anything against UTC.
Standard ... Daylight Savings
(Winter) Abb (Summer) Abb
UTC-0500 EST UTC-0400 EDT Eastern
UTC-0600 CST UTC-0500 CDT Central
UTC-0700 MST UTC-0600 MDT Mountain
UTC-0800 PST UTC-0700 PDT Pacific
However there is no International Standard for Time Zone Names, EST could be Eastern Standard Time (US), European Summer Time, or Eastern Standard Time (Australia).
It is best to use the +0430 and -0500 notation, because this instantly shows what the actual offset is. This notation does need all four digits as there a number of time zones that are 15, 30, or 45 minutes from being a full hour offset to UTC.
When calculating the Time elsewhere on the planet, don't forget that the date changes where the time passes through midnight. Also note that clocks in Britain run on GMT (UTC+0000) in Winter, but that in the Summer a clock on the wall in Britain, uses BST (British Summer Time) which is one hour ahead (UTC+0100). So, do not fall into the trap of calculating the offset from the time someone in Britain tells you. Refer directly to a UTC time source.
[edited by: g1smd at 7:37 pm (utc) on Sep. 19, 2002]
I would use Eastern, since those of us on the Left coast are more used to converting and having the wrong time zone than are people on the Right coast.
Tom
Don't forget that some states do have Daylight Savings Time in the summer while others do not. In some states, some counties observe DST, while other counties within the same state do not. Too confusing.
You referred to 'GMT' in an earlier posting. Don't forget that term went obsolete back in 1971, when it was replaced by UTC. The term GMT is best avoided as it reflects the local time zone used in the UK only in the Winter. Clock time in the UK is currently not GMT; it is BST, which is UTC+0100.
I know that but I think GMT is more known by people than UTC.
The UK time now can be both explained as GTM +1:00 and UTC +1:00.
Yes, it _could_ be explained as GMT+1:00, but this tends to confuse people who are outside the UK. Someone in the US, perhaps, knows his time zone as -5 hrs. In Summer the Time at Greenwich is GMT+1, and this can therefore lead to the person in the US taking 5 hours off the time at Greenwich, rather than 5 hours off the GMT time. This is why the offset to UTC is used. It then becomes clear that the UK time zone isn't GMT for over 7 months of the year.
In effect the old way was to say that 'Greenwich = GMT+1' in Summer. For time zone calculations you should have been using GMT as the base, but people inadvertently use the 'Greenwich civil time' which in Summer is known as BST (British Summer Time) and therefore get an answer that is one hour wrong for a part of the year.