I need a little help. Let's say I have two tables: values and periods. In the values table i save values for every day and for each hour. The format is like that:
ID | Value | Hour | PeriodID | Datetime
The PeriodID references to the other table (periods) where I save the object id and the local date in format YYYY-mm-dd.
In the values table the Datetime must be a centralized time for example CET so i can compare different object for each hour.
For that reason i have a PHP GMT function which generates from a given date (Y-m-d H:i:s) new date time, based on the object timezone:
function gmt($date, $timezone) {
$h = abs($timezone);
$hm = $h * 60;
$ms = $hm * 60;
$timestamp = strtotime($date);
$gmt_timestamp = ($timezone >= 0) ? $timestamp+($ms) : $timestamp-($ms);
return gmdate("Y-m-d H:i:s", $gmt_timestamp);
}
Unfortunately i have a problem when the daylight saving time changes. In that situation i have missing (2016-10-30 02:00:00) and duplicate hours (2016-10-31 01:00:00), which is wrong:
11910345 | 4.0 | 01.00 | 300476 | 2016-10-30 01:00:00
11910346 | 3.0 | 02.00 | 300476 | 2016-10-30 03:00:00
...
11910363 | 2.0 | 22.00 | 300476 | 2016-10-30 23:00:00
11910364 | 2.0 | 23.00 | 300476 | 2016-10-31 00:00:00
11910365 | 2.0 | 24.00 | 300476 | 2016-10-31 01:00:00
11910366 | 1.0 | 00.00 | 300477 | 2016-10-31 01:00:00
How can i regenerate the new date which will produce me continuously datetimes without missing or duplicate dates ?
Thanks in advice