Does Date.today() return the current date based on the server's date? If so, how can I get the correct date for a user?
A:
You can use ajax to send back the user date created by javascript on the client machine.
vurte
2010-10-31 00:40:59
That's assuming the LOCALE or timezone information is set correctly on the user's machine.
Greg
2010-10-31 02:41:53
@Greg: And time too.
Mladen Jablanović
2010-10-31 06:54:13
Or you can use geotargeting to match the ip of the client machine with timetables.
vurte
2010-10-31 08:10:31
Wouldn't VPN confuse geotargeting? Or a corporate machine behind a company router? Not all machines are directly attached to the internet and the machine's IP or timezone might not be the same IP or timezone as the router seen by the server software.
Greg
2010-10-31 09:13:15
I think you can use this 2 ways and ask the user if the calculated time is really his current time.Other ways, if he has not set his time correctly on his pc AND in the same time uses proxy or vpn (which is located in a different country or timezone), I now can't think of an other way ...
vurte
2010-10-31 09:27:57
"ask the user if the calculated time is really his current time" - I like that. If you get it right then there's a touch of magic going on. If it's wrong, hopefully the user will appreciate that the code tried, and will then correct whatever is wrong, either in the app's settings or on their machine.
Greg
2010-10-31 22:42:01
A:
The best way is to ask the user what their timezone is. You can try to determine via software without asking them, but if the user has not set up their machine correctly you'll get an incorrect response. By asking you're giving them the choice to give a correct answer, or to lie to you if they are so inclined.
You might want to ask the same question over on SO's sibling User Interface
site.
Greg
2010-10-31 02:46:07