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

From: Date: Wed, 24 May 2017 14:12:24 +0000
Subject: Bug #74645 [Opn]: DateTime::format() and DateTimeInterval %i %s Leading Zeros and Documentation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209250@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 User updated by: jimgkraai at gmail dot com Reported by: jimgkraai at gmail dot com Summary: DateTime::format() and DateTimeInterval %i %s Leading Zeros and Documentation Status: Open Type: Bug Package: *General Issues 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: --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 Previous Comments: ------------------------------------------------------------------------ [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 (#209250) next »