This article mainly introduces the Strtotime usage of time plus and minus function in PHP, and analyzes the operation skill of date plus and minus operation by combining Strtotime with date function, which can be referenced by friends.
Time plus minus
<?php//gets the local fetch year +1$date=date ("Y-m-d", Mktime (0,0,0,date ("M"), Date ("D"), Date ("Y") +1)); >
What should you do if you want to get the time in the database? A good function strtotime is found in the PHP documentation, and the time can be added and reduced:
int strtotime ( string time [, int now] )
return type int
Functions can be used for time conversion and subtraction.
<?php//date () Format time returns a string type. Plus one year $date_year = date (' y-m-d ', Strtotime ("$date + 1 Year")), Echo $date _year;//plus Day $date_tomorrow = date (' y-m-d ', Strtotime ("2009-05-26 + 1 Day"), Echo $date _tomorrow;//plus one week $date_week = Date (' y-m-d ', Strtotime ("$date + 1 Week"); echo $ Date_week;? >
The above is the whole content of this article, I hope that everyone's study has helped.