php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25530 Function checkdate() accepts float values as valid parameters
Submitted: 2003-09-14 05:32 UTC Modified: 2003-09-14 20:06 UTC
From: jlamberg at cc dot helsinki dot fi Assigned:
Status: Closed Package: Date/time related
PHP Version: 4CVS-2003-09-14 (stable) OS: WinXP Pro
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:
44 - 18 = ?
Subscribe to this entry?

 
 [2003-09-14 05:32 UTC] jlamberg at cc dot helsinki dot fi
Description:
------------
Function checkdate(mon, day, year) accepts float values as valid parameters.

Reproduce code:
---------------
$day1 = 13.7;
$mon1 = 5.1;
$year1 = 2000.75;

if (checkdate($mon1, $day1, $year1))
  echo "Valid date";
else
  echo "Invalid date";

$day2 = "4e4";
$mon2 = 5.1;
$year2 = "2000.75";

if (checkdate($mon2, $day2, $year2))
  echo "Valid date";
else
  echo "Invalid date";


Expected result:
----------------
I expected the script to echo two times 'Invalid date' since only integer parameters should be accepted.

Actual result:
--------------
The script echoed two times 'Valid date'. The first date is a clear case. I guess the second date is considered valid because of the string "4e4" being taken as "4" (the number 4), which is also wrong.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-14 20:06 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot 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 in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC