php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74517 Incorrect date string to int conversion
Submitted: 2017-05-01 00:10 UTC Modified: 2017-05-01 07:14 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: apollo880 at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: All systems
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:
27 - 17 = ?
Subscribe to this entry?

 
 [2017-05-01 00:10 UTC] apollo880 at gmail dot com
Description:
------------
An incorrect date string to int conversion in strtotime() with use the YYYY-MM-DD format

Test script:
---------------
echo strtotime('1996-12-01') // return 849387600, it's OK
echo strtotime('1996-11-31') // return 849387600, it's FAIL, this date not exists, need return false 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-01 07:14 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: *General Issues +Package: Date/time related
 [2017-05-01 07:14 UTC] requinix@php.net
strtotime will try to come up with the most reasonable date it can from the string passed. Dates with invalid month or day numbers will underflow or overflow.

If you want validation then use DateTime and its getLastErrors().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 18:01:31 2024 UTC