|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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);
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 05:00:02 2025 UTC |
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.