php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78478 DateTime is formatting wrongly
Submitted: 2019-08-30 15:06 UTC Modified: 2019-09-02 07:24 UTC
From: jmriera at oqpbcn dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: Centos
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jmriera at oqpbcn dot com
New email:
PHP Version: OS:

 

 [2019-08-30 15:06 UTC] jmriera at oqpbcn dot com
Description:
------------
The format method in the date time is formatting wrongly

Test script:
---------------
$do=DateTime::createFromFormat('F-y','February-18');
echo $do->format("Y-m-d H:i:s").'<br>';

The result is outside of the February month
2018-03-02 16:49:08

Expected result:
----------------
2018-02-?? ...

Actual result:
--------------
The result is outside of the February month
2018-03-02 16:49:08

Patches

OQP (last revision 2019-08-30 15:18 UTC by jmriera at oqpbcn dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-30 15:18 UTC] jmriera at oqpbcn dot com
The following patch has been added/updated:

Patch Name: OQP
Revision:   1567178307
URL:        https://bugs.php.net/patch-display.php?bug=78478&patch=OQP&revision=1567178307
 [2019-08-30 15:26 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2019-08-30 15:26 UTC] requinix@php.net
Today is August 30th. Asking for a date in February 2018 will give you February 30th, 2018. That overflows into March.

Perhaps you want to use the ! modifier?
 [2019-09-02 07:24 UTC] jmriera at oqpbcn dot com
Ok I understand.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 21:01:27 2025 UTC