PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #25598 strtotime can't handle dates before 1970, and the documentation doesn't say it.
Submitted:18 Sep 2003 5:57pm UTC Modified: 19 Nov 2003 8:01am UTC
From:bens at benjamindsmith dot com Assigned to:
Status:Closed Category:Documentation problem
Version:4.3.2 OS:2.4.x Linux, Windows
Votes:3 Avg. Score:4.0 ± 0.8 Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%) Same OS:2 (66.7%)
View/Vote Developer Edit Submission

Welcome! If you don't have a SVN account, you can't do anything here. You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
SVN Username: SVN Password:
Quick Fix:
Status: Assign to:
Category:
Summary:
From: bens at benjamindsmith dot com
New email:
Version: OS:
New/Additional Comment:

[18 Sep 2003 5:57pm 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

[13 Oct 2003 5:30am 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?
[19 Nov 2003 8:01am UTC] didou@php.net
Fixed in CVS :)

Hartmut, this was mentionned in strftime() but too specific to make an
entity.

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC