php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #25598 strtotime can't handle dates before 1970, and the documentation doesn't say it.
Submitted: 2003-09-18 17:57 UTC Modified: 2003-11-19 08:01 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: bens at benjamindsmith dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.2 OS: 2.4.x Linux, Windows
Private report: No CVE-ID: None
 [2003-09-18 17:57 UTC] bens at benjamindsmith dot com
Description:
------------
No matter what I do, strtotime can't seem to handle dates prior to 1970. The answer returned is always -1. 

The manual doesn't indicate this fact. 

Reproduce code:
---------------
echo phpversion();
echo "\n------------------\n";

$time1="1/1/1970";
$time2="31-dec-1969";
$time3="31-dec-1949";

echo strtotime($time1);
echo "\n";
echo strtotime($time2);
echo "\n";
echo strtotime($time3);
echo "\n";

Expected result:
----------------
4.3.2
-----------------
28800
-{some integer other than 1} 
-{some bigger integer other than 1} 

Actual result:
--------------
4.3.2
------------------
28800
-1
-1


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-13 05:30 UTC] hholzgra@php.net
UNIX timestamps for dates before Jan 1st 1970 are undefined anyway

some platforms treat negative timestamps as dates before 1970 while others just consider negative values as undefined ... so this is a 'won't fix' problem unless we come up with a portable PHP C-lib ;)

AFAIR this *is* documented in other places in the manual?
 [2003-11-19 08:01 UTC] didou@php.net
Fixed in CVS :)

Hartmut, this was mentionned in strftime() but too specific to make an entity.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 07:01:28 2024 UTC