I am using PHP to print the current timestamp using time() and I have a MySQL column which stores the date, which I am converting to a timestamp using strtotime(). However, when I print the converted values, I have a one hour difference between them. The real difference is in seconds. What’s wrong?
I am using PHP to print the current timestamp using time() and I have
Share
Assuming they both run on the same physical server, it is probably a timezone mismatch.
You can check the timezone on your MySQL server by running the following query in the MySQL console:
And on your PHP page by running a script with:
Once you figure out which one is wrong, you should be able to fix this by editing my.cnf or php.ini.
You can also change the default timezone on runtime using date_default_timezone_set().