Bug #70811 [NEW]: Future date calculation error if DST
From: ricardosanchez at orangemail dot es
Operating system: Linux
PHP version: 5.6.14
Package: Date/time related
Bug Type: Bug
Bug description:Future date calculation error if DST
Description:
------------
---
From manual page: http://www.php.net/function.strtotime
---
strtotime( $date . ' +24 hours' ) adds +1 extra hour if between these
+24 hours changes happens a DST change (equivalent to add +25 hours
instead +24 hours in case of one hour delayed due to DST time change)
Test script:
---------------
// For a start date (before DST - Daily Save Time change (3am -> 2am
again...))
$date_start = '2015-10-20 15:00';
// Two ways to add 168 hours (7 days). DST changes on 2015-10-25, so
result expected is 2015-10-27 14:00 (2015-10-20 15:00 +168 hours)
$date_end_ok = date( 'Y-m-d H:i', strtotime( $date_start ) + 168 * 3600
); // It adds 168 hours OK >> Result: 2015-10-27 14:00
$date_end_error = date( 'Y-m-d H:i', strtotime( $date_start . ' +168
hours' ) ); // It adds 169 hours instead! >> Result 2015-10-27 15:00
echo "Date initial $date_start - date limit OK (+168 * 3600) :
$date_end_ok >> date limit ERROR (+168 hours) $date_end_error";
Expected result:
----------------
$date_end_ok and $date_end_error must be the same => +168 hours OK:
2015-10-27 14:00
Actual result:
--------------
$date_end_error = date( 'Y-m-d H:i', strtotime( $date_start . ' +168
hours' ) ); // It adds 169 hours instead 168 hours, because on
2015-10-25 an hour is delayed due DST time change! >> Actual result
2015-10-27 15:00
--
Edit bug report at https://bugs.php.net/bug.php?id=70811&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70811&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70811&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70811&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70811&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70811&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70811&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70811&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70811&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70811&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70811&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70811&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70811&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70811&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70811&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70811&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70811&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70811&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70811&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70811&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70811&r=mysqlcfg
Thread (3 messages)
- ricardosanchez at orangemail dot es