The following code worked before, but failed to get the next 4 days of today 2011-11-04
$draw_date = '2011-11-04';
$ts = strtotime($draw_date) + 86400*4;
$ddate = date('Y-m-d', $ts);
echo $ddate;
The code above print 2011-11-07, but what I expected is 2011-11-08. It works if I set draw_date = '2011-10-04' or '2011-12-04'. Very weird! Can anyone explain why?
Thanks in advance.
You can use:
$ts = strtotime($draw_date) ;
strtotime('+4 day', $ts);
Don't forget there's a DST switchover on November 6th. That makes 4days-from-now actually be 86400*4 + 3600 for the extra hour.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.