|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-10 09:16 UTC] derick@php.net
[2004-11-15 17:35 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 22:00:02 2025 UTC |
Description: ------------ This seems related to the open bug involving "now" resetting to midnight of the current day, but it's not identical. If you try to adjust a time by passing strtotime() an offset like "+2 hours", you get that offset relative to midnight. In other words, strtotime("+2 hours", $unixtimestamp) returns a timestamp for 2 a.m, of the day referenced by $unixtimestamp, or of the current day if the second argument is omitted. Reproduce code: --------------- // in PHP 4, this correctly returns 3:30 p.m. on Jan 1, 2005 but in PHP 5.0.1 returns 2:00 a.m. on Jan 1, 2005: $timeStamp = strtotime("+2 hours", strtotime("1/1/2005 1:30pm")); echo date("r", $timeStamp); // in PHP 4, this correctly returns a date/time for two hours from now, but in PHP 5.0.1 it returns 2 a.m. on the current day: $timeStamp = strtotime("+2 hours"); echo date("r", $timeStamp); Expected result: ---------------- two hours from given date and time or from now, depending on whether a second timestamp argument was provided to strtotime(); Actual result: -------------- 2 a.m. on relevant date.