Doc #54402 [NEW]: Format string not documented correctly for %I minutes and $S seconds
| From: | tom dot haws at gmail dot com | Date: | Sun, 27 Mar 2011 16:25:10 +0000 |
| Subject: | Doc #54402 [NEW]: Format string not documented correctly for %I minutes and $S seconds | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-6154@lists.php.net to get a copy of this message | ||
From:
Operating system: Ubuntu
PHP version: 5.3SVN-2011-03-27 (snap)
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Format string not documented correctly for %I minutes and $S seconds
Description:
------------
---
From manual page: http://www.php.net/datetime.format#Parameters
---
Note about the time diff format string:
As far as I can tell, the datetime diff format string I ended up using is
not documented anywere. The PHP manual says that the format string for the
time diff is a "format accepted by date()". That would look like 'Y-m-d
H:i:s', but that did not work. The other documented format I could find is
the one accepted by strftime. That would look like '%Y-%M-%D %H:%i:%s', but
that did not give leading zeroes for minutes and seconds.
$my_birth_tz=new DateTimeZone('America/Phoenix');
$my_birth=new DateTime('1956-09-19 08:38:00',$my_birth_tz);
$my_marriage_tz=new DateTimeZone('America/Los_Angeles');
$my_marriage=new DateTime('1981-12-14 11:38:00', $my_marriage_tz);
$my_marriage_age=$my_marriage->diff($my_birth);
echo $my_marriage_age->;format('%Y-%M-%D %H:%I:%S');
// Result: 25-02-25 04:00:00
Test script:
---------------
$my_birth_tz=new DateTimeZone('America/Phoenix');
$my_birth=new DateTime('1956-09-19 08:38:00',$my_birth_tz);
$my_marriage_tz=new DateTimeZone('America/Los_Angeles');
$my_marriage=new DateTime('1981-12-14 11:38:00', $my_marriage_tz);
$my_marriage_age=$my_marriage->diff($my_birth);
echo $my_marriage_age->;format('%Y-%M-%D %H:%I:%S');
// Result: 25-02-25 04:00:00
// Note the non-documented format() string.
echo $my_marriage_age->;format('%Y-%M-%D %H:%i:%s');
// Result: 25-02-25 04:0:0
// Expected 25-02-25 04:00:00 from the documented format string.
Expected result:
----------------
// Expected 25-02-25 04:00:00 from the documented format string.
I wanted leading zeros.
Actual result:
--------------
// Result: 25-02-25 04:0:0
No leading zeros.
--
Edit bug report at http://bugs.php.net/bug.php?id=54402&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54402&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54402&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54402&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54402&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54402&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54402&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54402&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54402&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54402&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54402&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54402&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54402&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54402&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54402&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54402&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54402&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54402&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54402&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54402&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54402&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54402&r=mysqlcfg