Req #65608 [Opn->Nab]: Possible problems with the UNIX timestamp
| From: | rasmus@php.net | Date: | Wed, 04 Sep 2013 02:47:48 +0000 |
| Subject: | Req #65608 [Opn->Nab]: Possible problems with the UNIX timestamp | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181417@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65608&edit=1
ID: 65608
Updated by: rasmus@php.net
Reported by: jiri dot kapinus at gmail dot com
Summary: Possible problems with the UNIX timestamp
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: Date/time related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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