Bug #74645 [Opn->Nab]: DateTime::format() and DateTimeInterval %i %s Leading Zeros and Documentation

From: Date: Wed, 24 May 2017 14:16:02 +0000
Subject: Bug #74645 [Opn->Nab]: DateTime::format() and DateTimeInterval %i %s Leading Zeros and Documentation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209251@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74645&edit=1 ID: 74645 Updated by: requinix@php.net Reported by: jimgkraai at gmail dot com Summary: DateTime::format() and DateTimeInterval %i %s Leading Zeros and Documentation -Status: Open +Status: Not a bug Type: Bug -Package: *General Issues +Package: Date/time related Operating System: redhat 2.6.32-696.1.1.el6.x86_64 PHP Version: 5.6.30 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 $time_interval is a DateInterval. It has its own format() with its own formatting rules. http://php.net/manual/en/datetime.diff.php http://php.net/manual/en/dateinterval.format.php Previous Comments: ------------------------------------------------------------------------ [2017-05-24 14:12:21] jimgkraai at gmail dot com --https://secure.php.net/manual/en/datetime.format.php states --- "I (capital i) Whether or not the date is in daylight saving time" which is not minutes with leading zero --- 'S' is not in the list of format characters should read https://secure.php.net/manual/en/function.date.php states - "I (capital i) Whether or not the date is in daylight saving time" which is not minutes with leading zero - 'S' is not in the list of format characters ------------------------------------------------------------------------ [2017-05-24 14:08:23] jimgkraai at gmail dot com Description: ------------ --- From manual page: http://www.php.net/datetime.format --- DateTime::format() does not add leading zeros for the %i and %s format characters as documented. https://secure.php.net/manual/en/datetime.format.php "Parameters/format" states "Format accepted by date()." https://secure.php.net/manual/en/datetime.format.php states - "I (capital i) Whether or not the date is in daylight saving time" which is not minutes with leading zero - 'S' is not in the list of format characters The actual behavior of DateTime::format() is not properly documented. Note that similar behavior/documentation dissonance exists for DateTimeInterval::format() Test script: --------------- <?php $time_start = new DateTime('now'); sleep(60*2+3.1415926535897961646); $time_end = new DateTime('now'); $time_interval=$time_end->diff($time_start); echo $time_interval->format("%H:%i:%s seconds") . PHP_EOL; echo $time_interval->format("%H:%I:%S seconds") . PHP_EOL; // <- not documented for DateTime::format() ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74645&edit=1

« previous php.bugs (#209251) next »