php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #17190 Date() gives error for date prior to 1-1-1970
Submitted: 2002-05-13 17:31 UTC Modified: 2002-05-24 14:59 UTC
From: mfconstable at pacbell dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.2.0 OS: Windows NT 4.0
Private report: No CVE-ID: None
 [2002-05-13 17:31 UTC] mfconstable at pacbell dot net
When using date() to format date prior to Jan 1, 1970  or after Jan 19, 2038 PHP gives

Warning: unexpected error in date()

script
\\variable's byear,bmonth,bday come from user form
\\script works fine for dates between 1-1-1970 - 1-19-2038
$bdate = $byear . "-" . $bmonth . "-" . $bday ;
$dob = strtotime($bdate); 
$_SESSION['view_dob'] = date("d-m-Y",$dob);

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-14 02:19 UTC] derick@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.

This is a problem in Windows, not in PHP.

Derick
 [2002-05-14 03:53 UTC] mfischer@php.net
Reopening as a documentation problem.

I threw a quick glance on the php.net/date page last night and I couldn't find it there. If it's nere, it needs to be outlined better, or well, documented at all.
 [2002-05-14 04:08 UTC] sitnikov at infonet dot ee
Look also www.php.net/strtotime
 [2002-05-22 06:50 UTC] darkelder@php.net
I'm using PHP 4.1.2 and no error on date() as got on:

<?PHP
error_reporting(E_ALL);
$time = strtotime("1850-10-10");
if ($time == -1)
{
        print "Invalid date range\n";
}
print date("d-m-Y",$time);

?>


The only error is that date will allways show the date of time = -1 on invalid range (< 1970  OR > 2038).

Is only a code bug. You should verify if $time is -1.



 [2002-05-22 06:52 UTC] darkelder@php.net
Please, someone check on Windows the routine I wrote.  Maybe on Windows date() return error if time is -1.
 [2002-05-22 13:29 UTC] tom@php.net
Yep,

the exact output is

Invalid date range
Warning:  unexpected error in date() in D:\Test\t.php on line 8

 [2002-05-24 14:59 UTC] derick@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Aug 19 16:01:27 2024 UTC