I have this code:
$date = '2010-03-08 8:10:20'
$new_date = date('Y-m-d H:i:s', strtotime($date . " +1 month"));
echo $new_date;
Btw, I already set
date_default_timezone_set('Europe/London');
And the result is: 5 April 2010, 3 days missing. Why is it happen? I heard they are some bugs in strtotime? If thats the case, how to get a correct one? I mean, is there another way to replace this:
$new_date = date('Y-m-d H:i:s', strtotime($date . " +1 month")); // or +2, +3... +100
使用mktime函数:
$date = date ( 'Y-m-d H:i:s', mktime ( arguments ) + one_month_epoch_value) ) ;
I do this:
date_default_timezone_set('Europe/London');
$date = '2010-03-08 8:10:20';
$new_date = date('Y-m-d H:i:s', strtotime($date . " +1 month"));
echo $new_date;
and get
2010-04-08 08:10:20
so you've got some other issue.
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.