Req #65608 [Opn]: Possible problems with the UNIX timestamp
| From: | jiri dot kapinus at gmail dot com | Date: | Tue, 03 Sep 2013 08:45:59 +0000 |
| Subject: | Req #65608 [Opn]: Possible problems with the UNIX timestamp | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181403@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
User updated by: jiri dot kapinus at gmail dot com
Reported by: jiri dot kapinus at gmail dot com
Summary: Possible problems with the UNIX timestamp
Status: Open
Type: Feature/Change Request
Package: Date/time related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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"
Previous Comments:
------------------------------------------------------------------------
[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