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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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)

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 13:01:30 2024 UTC