Req #74797 [Opn]: strtotime() doesn't accept date with spaces in it
| From: | derick@php.net | Date: | Thu, 22 Jun 2017 21:25:25 +0000 |
| Subject: | Req #74797 [Opn]: strtotime() doesn't accept date with spaces in it | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209633@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74797&edit=1
ID: 74797
Updated by: derick@php.net
Reported by: hofman dot tomas at gmail dot com
Summary: strtotime() doesn't accept date with spaces in it
Status: Open
Type: Feature/Change Request
Package: Date/time related
PHP Version: Next Minor Version
Block user comment: N
Private report: N
New Comment:
strtotime can't possibly support *all* formats in existence, that's why you can use
DateTime::createFromFormat instead:
https://3v4l.org/dXWqD
Previous Comments:
------------------------------------------------------------------------
[2017-06-22 14:15:09] hofman dot tomas at gmail dot com
Description:
------------
It will be nice, that strtotime() function could parse date format with dots and spaces to. Now
strtotime('22.6.2017') returns 1498082400, but typographicaly correct version
strtotime('22. 6. 2017') returns false. In some languages/typographic convetions (like
Czech or German) format with spaces is correct, but strtotime() not supports it. Is it possible to
have also this one?
Test script:
---------------
<?php
echo var_dump(strtotime('22.6.2017'));
echo var_dump(strtotime('22. 6. 2017'));
?>
Expected result:
----------------
int(1498082400)
int(1498082400)
Actual result:
--------------
int(1498082400)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74797&edit=1