How can I insert into the db, the datetime in the users time?
I've looked at a couple of things and either a) they don't work or b) I don't understand fully what is going on.
Any help would be great.
11:59 pm on Aug 16, 2010 (gmt 0)
If you are using the time() function to return a Unix timestamp, you can take away or add the amount of seconds. 3600 is 1 hour. In your case, there is a 7 hour difference in front of the server time, so you want:
$timestamp = time(); $timedifference = 25200; // 3600 multiplied by amount of hours $newtimestamp = $timestamp + $timedifference;
echo $newtimestamp . '<br />'; date ('d-m-Y,h:i:s',$newtimestamp);
6:10 am on Aug 17, 2010 (gmt 0)
If you are using PHP5, use date_default_timezone_set [php.net] to set the correct timezone for your clients, based on their location. All date and time functions will automatically be correct.