php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28399 Getting unixtime since 12/31/1969 21:00:00
Submitted: 2004-05-14 15:23 UTC Modified: 2004-05-14 15:49 UTC
From: vinicius at teracom dot com dot br Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.4 OS: Red Hat 8.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vinicius at teracom dot com dot br
New email:
PHP Version: OS:

 

 [2004-05-14 15:23 UTC] vinicius at teracom dot com dot br
Description:
------------
I was testing unixtime from php and delphi and there is a difference from one to another. 

Php makes unixtime from 12/31/1969 21:00:00. Isn't it a bug? Unixtime isn't from 01/01/1970 00:00:00 as you say in manual from function strtotime:

'...This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems....'

If it's because the time, isn't it needed another argument to define it? 

For example:

If i make a script using unixtime using -0300 timezone and, for some reason, i move it to another system that uses timezone as GMT, some results will be different.

Reproduce code:
---------------
<?                    
$unixtime = 0;
echo date("d/m/Y H:i:s", $unixtime) . "\r\n";
?>


Expected result:
----------------
01/01/1970 00:00:00

Actual result:
--------------
31/12/1969 21:00:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-14 15:34 UTC] iliaa@php.net
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

This data is retrieved from your OS, PHP has little to do 
with this. 
 [2004-05-14 15:49 UTC] mgf@php.net
This is expected behaviour -- the Unix epoch is 1-Jan-1970 00:00 *GMT*, so a timestamp of 0 of course equates to 31-Dec-1969 21:00 in a GMT-0300 timezone.  This is clearly documented in the same note that you quote from: "valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT"

(See also date()/gmdate(), mktime()/gmmktime().)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Aug 12 18:00:03 2025 UTC