PHP HELP: DATE-TIME and TIMEZONE handling

iosoft

PC enthusiast since MS DOS 5
Skilled
Hi Devs,

I am little confused about displaying DATE-TIME with respect to users TIMEZONE.

Here is the scenario -

There are 3 entities -
  • SERVER, located in the GMT
  • USER1, in India (+5:30)
  • USER2, in Somewhere else, say at (-1:30)
This is basically a PHP based Commenting System.

Say, current Server time is 12'mid-night, that is 00:00.
USER1 posts a comment.
Now, the Questions -
  • What will be the time-stamp on that POST ?
  • Should I store the POST time-stamp on the basis of USER1's time, or Server's time ?
  • What will be the time USER2 seeing ?

Entire System is ready but got confused when I want to implement the TIMEZONE correction :S

BTW: POST means Comment posted, not the POST method ;)
 
There are two possible solutions
1.Have a base time zone and stick to it. All users posting will have timestamp wrt the base timezone.

2.Show timestamps on the basis of timezone of logged in user. All other posts
(from other timezones) to be converted to logged in users timezone.
Solution no.1 is more feasible and practical
 
is it not possible for u to pick up / read the time frm the users system.....this is the same i have executed on a feedback form for my companies website....since we have users from all over the world filling up the same i added a script which stamps the form and fills up the date / time field with the date and time of the 'current' user....u can impliment the same....
 
Use a single base time and try to stick to it. If you don't, believe me you will be left your hair. On php, you can try gmmktime or gmdate functions.
 
Stick to Server's time stamp as the base.

You can easily convert to any other timestamp by using function convertTZByID("timezone").

You can have the user set his preference, and server will convert the date based on his preference or to a default (if not set).
 
Safin said:
Use a single base time
What do you mean by this 'base time' ? Server's Time ?
Safin said:
you will be left your hair.
You are right.... I already lost many hair.
Created a sexy interface but facing time-zone issue.
Also, should I use PHP to convert the time or directly from MySQL using MySQL function(s) ?
 
Back
Top