[eluser]insub2[/eluser]
Is there anyway to access the client's current time with only PHP? I know one can use Javascript to get that and then pass it to the PHP. ...I'm asking out of curiosity mostly.
[eluser]TheFuzzy0ne[/eluser]
I think so, but not directly. I'm sure it's possible to trace an IP to locale and work the time out from that, although this fails if an IP address is spoofed, rerouted, or coming through a proxy.
[eluser]Dam1an[/eluser]
As far as I know, the only way to do it with pure PHP is based on the users IP address, and as Fuzzy said, this information can be unrelaibale. The reasoning is because PHP is all server side, so by the time it leaves for the clients machine, its just HTML (and JS etc)
[eluser]slowgary[/eluser]
You could also just ask them for their time zone. Keep in mind that the JS method will give you the time that the client COMPUTER is set to, not necessarily the correct time for the user of that computer. For that reason, the JS method can't really be trusted, as the user could set their time 3 years ahead and trick your app, whereas if you ask them their time zone, you're still determining the correct time.
[eluser]TheFuzzy0ne[/eluser]
I agree, JS and IP to locale are good for guessing, and might be convenient for your users, but the best way is to simply ask them.
[eluser]Dam1an[/eluser]
Or as Colin said, use the JS/IP method to guess it, and then just ask the user to confirm it, 9 times out of 10, they won't need to do anything, as its already correct
[eluser]Thorpe Obazee[/eluser]
In one app we did, we used javascript to determine the time. of course, it's not that reliable since it'll depend on the client's system time.