Hi, I am experiencing strange behavior with php date () function. I am trying to increase the dates by a week at such a time.
CODE:
<?php date_default_timezone_set('Europe/London'); echo 7*24*60*60; echo '<br>'; echo date('d/m/YH:i:s', 0); echo '<br>'; echo date('d/m/YH:i:s', 604800); ?>
The result is the following result.
OUTPUT:
604800 01/01/1970 01:00:00 08/01/1970 01:00:00
As expected, the date increased by 7 days to a second. But after I reach a certain number of seconds, the date function seems to lose an hour from the date.
CODE:
<?php date_default_timezone_set('Europe/London'); echo (1351468800 - 1350864000); echo '<br>'; echo date('d/m/YH:i:s', 1350864000); echo '<br>'; echo date('d/m/YH:i:s', 1351468800); ?>
Next release results
OUTPUT:
604800 22/10/2012 01:00:00 29/10/2012 00:00:00
As you can see, the date has lost an hour, although the difference between the two dates is 604800 seconds. I tested this on two different servers, and I also tested similar code using a DateTime object, but still the same result. Where am I mistaken?
source share