php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51376 date_parse_from_format no leading zero
Submitted: 2010-03-24 09:41 UTC Modified: 2010-03-24 18:16 UTC
From: george at shoutbomb dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.2 OS: Windows
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: george at shoutbomb dot com
New email:
PHP Version: OS:

 

 [2010-03-24 09:41 UTC] george at shoutbomb dot com
Description:
------------
date_parse_from_format("Ymd","20100323") returns... no leading zero in the month

Test script:
---------------
<?php
print_r(date_parse_from_format("Ymd","20100323"));
?>

Expected result:
----------------
Array
(
    [year] => 2010
    [month] => 03
    [day] => 23
    [hour] => 
    [minute] => 
    [second] => 
    [fraction] => 
    [warning_count] => 0
    [warnings] => Array
        (
        )

    [error_count] => 0
    [errors] => Array
        (
        )

    [is_localtime] => 
)

Actual result:
--------------
Array
(
    [year] => 2010
    [month] => 3
    [day] => 23
    [hour] => 
    [minute] => 
    [second] => 
    [fraction] => 
    [warning_count] => 0
    [warnings] => Array
        (
        )

    [error_count] => 0
    [errors] => Array
        (
        )

    [is_localtime] => 
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-24 10:01 UTC] derick@php.net
-Status: Open +Status: Bogus
 [2010-03-24 10:01 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

They are parsed and stored as integers, not as strings.
 [2010-03-24 18:16 UTC] george at shoutbomb dot com
-Type: Bug +Type: Documentation Problem
 [2010-03-24 18:16 UTC] george at shoutbomb dot com
I re-read http://us.php.net/manual/en/function.date-parse-from-format.php and 
there is no mention of parsing as 'integer'.  If the function is accepting the 
"Format accepted by date() with some extras" that it should obey the formatting.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Dec 01 02:00:01 2025 UTC