<?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