php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76125 error date_create_from_format
Submitted: 2018-03-21 12:21 UTC Modified: 2021-04-06 18:31 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: denorian at yandex dot ru Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.0.28 OS: linux
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: denorian at yandex dot ru
New email:
PHP Version: OS:

 

 [2018-03-21 12:21 UTC] denorian at yandex dot ru
Description:
------------
Error in reading the date in the function date_create_from_format

Test script:
---------------
<?
$date = date_create_from_format("D, d M Y H:i:s O", "Tue, 20 Mar 2018 01:38:22 GMT");
echo date_format($date, 'Y-m-d');

//result 2018-03-20

$date = date_create_from_format("D, d M Y H:i:s O", "Tue, 21 Mar 2018 01:38:22 GMT");
echo date_format($date, 'Y-m-d');

//result 2018-03-27  27? Why?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-21 13:00 UTC] cmb@php.net
-Package: date_time +Package: Date/time related
 [2018-03-21 13:00 UTC] cmb@php.net
> //result 2018-03-27  27? Why?

Since there is no Tue, 21 Mar 2018, the parser apparently assumes
you've meant Tue, 27 Mar 2018 01:38:22 GMT.
 [2018-03-21 13:58 UTC] spam2 at rhsoft dot net
the parser should throw a warning

[builduser@testserver:/rpmbuild/SPECS]$ rpmlint fsync-tester.spec
fsync-tester.spec: E: specfile-error warning: bogus date in %changelog: Wed Feb 22 2018

because Wed is wrong, it was a tuesday
 [2021-04-06 18:31 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2021-04-06 18:31 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is expected behaviour, and is documented in the documentation: https://www.php.net/manual/en/datetime.formats.relative.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC