I have a Python application that stores the local time into a mySQL database and a PHP application that displays that date/time through a Web interface. I'm observing a constant offset (from GMT) of the displayed date/time.
I can find nothing in the PHP / Python documentation to explain this difference.
The Python application stores the local time:
import time
localTime = int(time.time())
The PHP application then retrieves the time and displays it:
date('n/j/y H:i:s', $bg['last_polled'])
where $bg retrieves the entry from the mySQL database.
Why don't these two agree on what localtime is (both applications are running on same server)
As noted above, the timezone needs to be explicitly set. Ideally in a php.ini file. As a practical matter, I found at least two instances of php.ini and decided to take the coward's way out and add the following to startup.php:
date_default_timezone_set('America/Louisville');
The timezones for the US are far from intuitive (and largely depricated. I see a lot of entries to cover Indiana when parts of the state ignored DST)
Are you storing a timestamp 2014-08-25 12:11:00
or a Unix Epoch 2147483647
? Check to see what data type PHP is reading and how it is displayed.
Since you are storing the date as an integer timestamp, I think the problem is on PHP side. Have you set PHP date.timezone INI setting correctly?
Here is some more info about that setting: http://php.net/manual/en/datetime.configuration.php#ini.date.timezone