php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #74797 strtotime() doesn't accept date with spaces in it
Submitted: 2017-06-22 14:15 UTC Modified: 2017-06-22 21:25 UTC
From: hofman dot tomas at gmail dot com Assigned:
Status: Open Package: Date/time related
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-06-22 14:15 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-22 21:25 UTC] derick@php.net
strtotime can't possibly support *all* formats in existence, that's why you can use DateTime::createFromFormat instead:

https://3v4l.org/dXWqD
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Oct 30 17:01:24 2020 UTC