Web Hosting Talk







View Full Version : Server's time seems to be messed up


Lord Northern
08-15-2007, 07:40 PM
Hello there.
I was trying to write some date/time comparing script and noticed that for some reason, the php script and the MySQL timestamp report different hours.
The time returned from MySQL seems to be correct while the one generated by a php script using the date() function seems to go one hours ahead.
Here's the exact input:

2007-08-16 03:28:39
2007-08-16 02:28:37

from the following script:

<?php
require_once "db_access.php";

$datedb=$db->getOne("SELECT date FROM time WHERE id='1'");
$currentdate=date('Y-m-d H:i:s');

echo ("$currentdate <br />");
echo $datedb;

?>What could be the reason?

foobic
08-15-2007, 08:43 PM
Daylight saving? Try this:
$currentdate=date('Y-m-d H:i:s e+I');
or even:
$currentdate=date('r');

Lord Northern
08-16-2007, 04:33 AM
oh, I see.
Thanks