PHP Date Operation method

Source: Internet
Author: User

<?PHP/** * Date addition and subtraction method in PHP*///The first step is to assume that there is a time$a= ' 2012-04-25 10:10:00 ';//Step Two, get the timestamp for this date$a _time=Strtotime($a);//step three, get the timestamp after five months plus$b _time=Strtotime(' +5 Month ',$a _time);//Fourth, convert the timestamp back to the date format$b=Date(' Y-m-d h:i:s ',$b _time);Echo' This is a date added five months later '.$b;//If you think the above code is too long, you can do it one line.$b=Date(' Y-m-d h:i:s ',Strtotime(' + '.$time.‘ Month ',Strtotime($a)));Echo' This is a date added five months later '.$b;?>
// PHP date plus minus days Date ("y-m-d",strtotime("2013-11-12 12:12:12 +1 Day"))  ; // PHP date plus minus days Date ("y-m-d",strtotime("2013-11-12 12:12:12 +1 Month"))  ; // PHP date plus minus days Date ("y-m-d",strtotime("2013-11-12 12:12:12 +1 Year"))  ;

PHP Date Operation method

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.