Interesting way of getting time difference btwn user/server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Interesting way of getting time difference btwn user/server

Post by jraede »

I've been struggling with this issue for a while, and I think I just figured it out. Interested to see what everyone thinks.

On each page I check to see if $_SESSION['user_time_diff'] has been set. If yes, do everything like normal. If no, grab the time from javascript, send it to PHP via AJAX, and the set the variable according to the hour difference of the user time and the server time.

If this viable? I know it won't work if people disable javascript, but in that case I can just make an educated guess.
Post Reply