ID:               39012
 Updated by:       [EMAIL PROTECTED]
 Reported By:      djmaze at planet dot nl
-Status:           Open
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Windows
 PHP Version:      5.1.6
 New Comment:

time() also returns a unix timestamp. A unix timestamp is always in UTC
so it is pointless to do -date('Z') there is that would shift the time
two hours into the past.
time() and gmdate('U') show the same time, and that is correct.

But feel free to make your own functions which implement the wrong
logic.


Previous Comments:
------------------------------------------------------------------------

[2006-10-02 18:05:57] djmaze at planet dot nl

You are contradicting.
Quote: Unix timestamps are always in GMT (=UTC) so there is no problem
here.

My server is set to CET which is currently GMT+2
time()-date('Z') = 1159724908 = UTC
gmdate('U') = 1159732108 = GMT+2

As you can see gmdate('U') is NOT UTC

I found so many more issues with the current date and time functions
that i'm planning to write my own php_utc extension with utcdate() and
utctime() functions with an explanation why.

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

[2006-10-02 09:41:45] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Unix timestamps are always in GMT (=UTC) so there is no problem here.

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

[2006-10-01 19:57:09] djmaze at planet dot nl

Description:
------------
gmdate('U') shows the incorrect unix epoch.

http://php.net/gmdate: 'Format a GMT/UTC date/time'
http://php.net/date: 'U = Seconds since the Unix Epoch (January 1 1970
00:00:00 GMT)'

After calling date_default_timezone_set() everything is messed up, or
is that the whole purpose but someone forgot to document it?


Reproduce code:
---------------
<?php
function get_unixts()
{
        return array(
        'time()'   => time(),
        'date(\'U\')' => date('U'),
        'date(\'Z\')'  => date('Z'),
        'gmtime' => (time()-date('Z')),
        'gmdate(\'U\')' => gmdate('U'),
        'gmdate(\'Z\')' => gmdate('Z'),
        'date_default_timezone' => date_default_timezone_get(),
        );
}
$def = get_unixts();
date_default_timezone_set('UTC');
$set = get_unixts();

echo '<html><body><table
border="1"><tr><td>type</td><td>normal</td><td>after set
UTC</td></tr>';
foreach ($def as $t => $v)
{
        echo "<tr><td>$t</td><td>$v</td><td>{$set[$t]}</td></tr>";
}
echo '</table></body></html>';
?>

Expected result:
----------------
type        normal      after set UTC
time()      1159732108  1159724908
date('U')   1159732108  1159724908
date('Z')   7200        0
gmtime      1159724908  1159724908
gmdate('U') 1159724908  1159724908
gmdate('Z') 0           0


Actual result:
--------------
type        normal      after set UTC
time()      1159732108  1159732108
date('U')   1159732108  1159732108
date('Z')   7200        0
gmtime      1159724908  1159732108
gmdate('U') 1159732108  1159732108
gmdate('Z') 0           0



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


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

Reply via email to