Bug #75816 [Opn->Nab]: Failed to parse time string (201501)

From: Date: Wed, 07 Feb 2018 17:40:55 +0000
Subject: Bug #75816 [Opn->Nab]: Failed to parse time string (201501)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213850@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75816&edit=1 ID: 75816 Updated by: jhdxr@php.net Reported by: 326956600 at 163 dot com Summary: Failed to parse time string (201501) -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: Ubuntu 16.04 PHP Version: 7.0.27 Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2018-01-31 13:41:16] saad dot achemlal at gmail dot com You must enter a valid input , something like '2015-01' will work but not '201501' ------------------------------------------------------------------------ [2018-01-15 07:16:00] 326956600 at 163 dot com Description: ------------ use DateTime() parse date error,such as Ym type:201501 、201512 I don't know user will input which time type,so i can't define a format like DateTime::createFromFormat('Ym', '201501') Test script: --------------- <?php $input = '201501'; $output = (new DateTime($input))->format('Ym'); echo $output; Expected result: ---------------- 201501 Actual result: -------------- 201801 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75816&edit=1

« previous php.bugs (#213850) next »