Pick up time can only choose two days after the order of time, how to write with PHP?

Source: Internet
Author: User
Pick up time can only choose two days after the order of time, how to write with PHP?

At present, the problem is that each month is not necessarily 31 days, and if the number of goods 30th, to choose the next month's time, this will be increased processing it? Thank you, guys.

Reply content:

Pick up time can only choose two days after the order of time, how to write with PHP?

At present, the problem is that each month is not necessarily 31 days, and if the number of goods 30th, to choose the next month's time, this will be increased processing it? Thank you, guys.

date('Y-m-d H:i:s',strtotime('+2 days'));

A different idea,
How many zodiac do you care for one months? Just use the time stamp to judge, right?

First Date +2
Then judge the month separately, note the February and leap years

Recent Python-written code 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");
  • 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.