The pick-up time can only be two days after the order is made. How can I write it in php? Currently, the problem is that not every month is 31 days. If the goods are set on the 30th, You need to select the next month's time. Should this be added? Thank you for choosing only two days after the order. How can I use php?
Currently, the problem is that not every month is 31 days. If the goods are set on the 30th, You need to select the next month's time. Should this be added? Thank you!
Reply content:
The pick-up time can only be two days after the order is made. How can I write it in php?
Currently, the problem is that not every month is 31 days. If the goods are set on the 30th, You need to select the next month's time. Should this be added? Thank you!
date('Y-m-d H:i:s',strtotime('+2 days'));
Another idea,
How many days have you taken care? Just use the timestamp to determine if it is okay?
Date + 2
Then judge the month separately. Pay attention to the month of February and the leap year.
The code written when I recently learned python is for reference only.
c_day += 2if ( c_day == 29 and c_month == 2 and not is_leap_year ) \ or ( c_day == 30 and c_month == 2 ) \ or ( c_day == 31 and (c_month == 4 or c_month == 6 or c_month == 9 or c_month == 11) ) \ or ( c_day == 32 and (c_month == 1 or c_month == 3 or c_month == 5 or c_month == 7 or c_month == 8 or c_month == 10) ) \ or ( c_day == 32 and c_month == 12 ): if c_day == 32 and c_month == 12: #when 12 year should increase c_year += 1 c_month = 1 is_leap_year = (c_year%400 == 0 or (c_year%4 == 0 and c_year%100 )) else: c_month += 1 c_day = 1
Http://cn2.php.net/manual/zh/class.datetime.php
$dateTime = new DateTime("now",new DateTimeZone("Asia/Chongqing"));$dateTime->modify("+2 day");echo $dateTime->format("Y-m-d");