php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66790 Convert date 0001-01-01 to unix timestamp
Submitted: 2014-02-27 12:29 UTC Modified: 2021-04-06 18:21 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: lampacz at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.4.25 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
27 - 10 = ?
Subscribe to this entry?

 
 [2014-02-27 12:29 UTC] lampacz at gmail dot com
Description:
------------
strtotime("0001-01-01") returns -62135600400 

Bash (date -d '0001-01-01' "+%s") returns -62135600264

Postgres (select extract(epoch from timestamp '0001-01-01');) returns  -62135600264

of course 64bit system

Test script:
---------------
echo strtotime("0001-01-01")

Expected result:
----------------
-62135600264

Actual result:
--------------
-62135600400

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-26 22:27 UTC] pedro dot bicudo at tgtconsult dot com dot br
Same code returns different results after php update:
$date=date_create("2014-01-01");echo date_timestamp_get($date);
php 5.3.26 returns 1388534400
php 5.3.28 returns 1388541600

$date=date_create("2014-06-14");echo date_timestamp_get($date);
php 5.3.26 returns 1402704000
php 5.3.28 returns 1402714800

this bug displays one day difference on screen depending on timezone
 [2021-04-05 15:42 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2021-04-05 15:42 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP --
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 [2021-04-06 18:21 UTC] lampacz at gmail dot com
ohh, after 7 years....

Version 7.3+ OK
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 02:01:30 2024 UTC