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: 2021-03-12 10:50 UTC
From: hofman dot tomas at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: Date/time related
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hofman dot tomas at gmail dot com
New email:
PHP Version: OS:

 

 [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
 [2021-03-12 10:50 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-03-12 10:50 UTC] cmb@php.net
I agree that we should not make strtotime() even more "flexible",
besides that we would need to implement our own parser, instead of
being able to use timelib_strtotime().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC