views:

29

answers:

1

I have a php script which gives server time, but as per knowledge, we can get the user's machine time and time zone with the help of client side scripts (javascript). I have mysql table which has dates stored along with timezone from where it was stored with the help of form. I need to show the data on a web page along with the time stored in the table, but it should be per user's machine.

rowid | date | timezone | data |
----------------------------------
12  | 2010-07-13 12:30:00 | Asia/Kolkata | This is data field |
143 | 2010-07-13 12:30:00 | Europe/Prague | This is data field |

Now, when I show date on web page, I need to show the above date per user's machine timezone.

A workaround logic would be that, if I could pass the date (2010-07-13 12:30:00) to some JS method which will take two time zone as input and convert the given date into user's machine's timezone. Or Something else?

Please help?

A: 

See the following link:

http://us3.php.net/manual/en/function.date-timezone-set.php

You can set the timezone in the script before displaying the dates although make sure you insert all the times in the DB as GMT.

Wright-Geek
How do I get visitor's timezone with php? It can be done with javascript only I think?
SachinKRaj
Sorry for the delay, the best way is to use javascript and then maybe have an ajax function push it to a session var. I have managed to do this many years ago with PHP using their IP Address and getting the details of that but was a huge headache
Wright-Geek