Edit report at https://bugs.php.net/bug.php?id=65608&edit=1

 ID:                 65608
 Comment by:         anon at anon dot anon
 Reported by:        jiri dot kapinus at gmail dot com
 Summary:            Possible problems with the UNIX timestamp
 Status:             Not a bug
 Type:               Feature/Change Request
 Package:            Date/time related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

The "bug" emerges from the assumption that if you take a time in time zone A, 
offset it by some amount, and then convert it to time zone B; you would get the 
same result as converting it to time zone B first, and then offsetting it.

Unfortunately, that assumption isn't true. Monticello used to be on Central 
Time. Now it's on Eastern Time.

It's definitely annoying, but it's not a bug in PHP. Time is HARD. For more 
pitfalls, see:
* 
http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time
* 
http://infiniteundo.com/post/25509354022/more-falsehoods-programmers-believe-about-time-wisdom


Previous Comments:
------------------------------------------------------------------------
[2013-09-04 02:47:48] ras...@php.net

I don't understand what you think the bug is here. Of course you can't just add 
the timestamp to the starting date for Unix time and expect it to work for all 
timezones. It completely ignores daylight savings along the way. If you can 
explain yourself better using a single timezone and prove that what you are 
seeing isn't simply the effect of daylight savings you can re-open this.

------------------------------------------------------------------------
[2013-09-03 08:45:59] jiri dot kapinus at gmail dot com

instead of ,,when convert this time to America/Kentucky/Monticello, it returns 
following date for Monticello timezone" 

is right this: 

,,when we set the time with parametr UNIX timestamp 0, it returns UNIX 
timestamp 
start time for Monticello timezone"

------------------------------------------------------------------------
[2013-09-03 08:28:49] jiri dot kapinus at gmail dot com

Description:
------------
The UNIX timestamp gives the number of seconds since January 1 1970 00:00:00 
UTC. 
But value of UNIX timestamp can be different, that in really is. More 
information 
on http://www.najdouvas.cz/unix-timestamp-error/

Test script:
---------------
<?php
date_default_timezone_set('UTC');
echo "Current time and date in UTC timezone: " . date("M d Y H:i:s", time()) . 
"<br>";
date_default_timezone_set('America/Kentucky/Monticello');
echo "Current time and date in America/Kentucky/Monticello timezone: " . 
date("M d Y H:i:s", time()) . "<br>";
echo "UNIX timestamp defined by Strtotime for now: " . strtotime("now")  . " 
<br>";
$start = strtotime("now");
$zonestart = date("M d Y H:i:s", 00);
echo "UNIX timestamp start at: Jan 01 1970 00:00:00 UTC<br>";
echo "when convert this time to America/Kentucky/Monticello, it returns 
following date for Monticello timezone<br>";
echo "UNIX timestamp start at:   " . $zonestart . " America/Kentucky/Monticello 
timezone<br>";
echo "To this date we add UNIX timestamp for NOW time. The result may be the 
same as the current time and date for America/Kentucky/Monticello <br>";
$date = date_create($zonestart);
$date->modify('+ ' . $start . ' sec');
echo "Result is: " . $date->format('M d Y H:i:s e') . "<br>";
date_default_timezone_set('UTC');
$date->setTimezone(new DateTimeZone("UTC")); 
echo "Changing this time to UTC timezone: " . $date->format('M d Y H:i:s e') . 
"<br><br>";
echo "When final date is not the same as the date at the begining, it means, 
that the UNIX timestamp don't give up exact number of second for this place or 
timezone. The UNIX timestamp gives the number of seconds since January 1 1970 
00:00:00 UTC. But it's different for different places.<br><br>";
?>



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65608&edit=1

Reply via email to