Bug #71489 [NEW]: date_parse_from_format does not work with unix timestamp

From: Date: Mon, 01 Feb 2016 14:24:38 +0000
Subject: Bug #71489 [NEW]: date_parse_from_format does not work with unix timestamp
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198984@lists.php.net to get a copy of this message
From: igorsantos07 at gmail dot com Operating system: Linux Mint 16 PHP version: 5.6.17 Package: Date/time related Bug Type: Bug Bug description:date_parse_from_format does not work with unix timestamp Description: ------------ Using date_parse_from_format() with a Unix Timestamp yields no error, but does not yields valid results as well. It sets the date to 1970-1-1, instead of the correct date. Test script: --------------- $ php -a Interactive mode enabled php > $unix = date('U'); php > echo $unix; 1454336317 php > echo date('Y-m-d H:i:s', $unix); 2016-02-01 12:18:37 php > print_r(date_parse_from_format('U', $unix)); Array ( [year] => 1970 [month] => 1 [day] => 1 [hour] => 0 [minute] => 0 [second] => 0 [fraction] => 0 [warning_count] => 0 [warnings] => Array ( ) [error_count] => 0 [errors] => Array ( ) [is_localtime] => 1 [zone_type] => 1 [zone] => 0 [is_dst] => [relative] => Array ( [year] => 0 [month] => 0 [day] => 0 [hour] => 0 [minute] => 0 [second] => 1454336317 ) ) Expected result: ---------------- It should fill in the array with "2016-02-01 12:18:37" info. Actual result: -------------- The array is filled with "1970-01-01", without error messages. -- Edit bug report at https://bugs.php.net/bug.php?id=71489&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71489&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71489&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71489&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71489&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71489&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71489&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71489&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71489&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71489&r=support Expected behavior: https://bugs.php.net/fix.php?id=71489&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71489&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71489&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71489&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71489&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71489&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71489&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71489&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71489&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71489&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71489&r=mysqlcfg

« previous php.bugs (#198984) next »