php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20113 time() does not work correctly !!
Submitted: 2002-10-26 20:53 UTC Modified: 2002-10-26 22:20 UTC
From: corinl at gmx dot de Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.2.2 OS: linux
Private report: No CVE-ID: None
 [2002-10-26 20:53 UTC] corinl at gmx dot de
hi, 
it seems that time() doens't work correctyl, either in mysql or php, but i thinks it's php. may be aynone can verify this ?

test-code:
    // check timestamps...
    $t1 = time();
    $sql = $theApp->sql->select_row("NOW() as t, UNIX_TIMESTAMP(NOW()) as s"); 
    $t2 = $sql['s'];
    $sqlt = $sql['t'];
    error_log("php: $t1, mysql: $t2, dif: ".($t2-$t1).", php-time: ".date("H:i:s").", sql-time: ".$sqlt);

outputs:
php: 1035683199, mysql: 1035679599, dif: -3600, php-time: 02:46:39, sql-time: 2002-10-27 02:46:39

as you can see, the date reported is the same but the timestamp exactly differs one hour. i think this is because of summer/winter time, but im not sure. so either mysql or php returns wrong timestamp !!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-26 22:20 UTC] sniper@php.net
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
Instead of using mktime/date consider using gmmktime and gmdate which do
not suffer from DST.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC