I'm working on an existing website which uses Unix timestamps for saving date/time information (as an INT UNSIGNED
column in MySQL).
If a user enters a date of 26th March 2017 with any time (the start of British Summer Time, when UK clocks go forward by an hour), when this is saved to the database and then extracted and displayed using date
, the time shown is one hour greater than that entered by the user. For example, 2017-03-26 20:00:00
when saved becomes 2017-03-26 21:00:00
when displayed. However, this only happens for 26th March 2017 - dates before and after show the same time as entered by the user.
I could understand if this was happening for every day after 26th March but I have no idea why it would only happen on one day. The site didn't have this problem last year either at the beginning or end of British Summer Time.
The default timezone is set to Europe/London (using date_default_timezone_set('Europe/London');
) in a file which is included on every page and phpinfo
also shows Europe/London as the default timezone.
The server time is correct and the date
command gives me: Fri 17 Mar 08:55:13 GMT 2017
.
The server has recently been upgraded which resulted in a version bump from PHP 5.3.x to 5.6.x so that is the only thing I can think of which may have caused this issue.
Is there anything I can do to resolve this, apart from using DATETIME fields (a longer term goal, but not something that can be done in a few days) or subtracting 3600 seconds from timestamps if their date is 26/03/2017 (gets very messy and there are too many places where timestamps are used for that to be practical).