The pick-up time can only be two days after the order is made. How can I write it in php?

Source: Internet
Author: User
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");
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.