PHP provides functions that can easily convert various forms of a date to a timestamp, which is mainly:
- Strtotime (): Resolves the datetime description of any English text to a timestamp.
- Mktime (): Gets the timestamp from the date.
Strtotime ()
The Strtotime () function is used to convert the date represented by the English text string to a timestamp, an inverse of date (), which returns the timestamp successfully, otherwise FALSE. Grammar:
int Strtotime (string time [, int now])
The parameter time is the parsed string and is the date represented by the GNU date input format.
Example:
";//output The timestamp of the present time tomorrow?>
Mktime ()
The Mktime () function is used to obtain a timestamp from a date, successfully returning a timestamp, or FALSE. Grammar:
int Mktime (time, minute, second, month, day, year)
Example:
Parameters can be omitted from right to left, and any omitted parameters are set to the current value of the cost date and time.
Mktime () is useful for date calculation and validation, and it automatically calculates the correct value for an out-of-range input. For example, the following example output is 2008-01-01:
The last day of next month. The last day of any given month can be represented as the "0" day of the next month, not 1 days, as in the following example:
Custom functions
The following function is similar to the Strtotime function.
echo Date ("Y-m-d h:i:s", $time _str);? >
http://www.bkjia.com/PHPjc/752397.html www.bkjia.com true http://www.bkjia.com/PHPjc/752397.html techarticle PHP provides functions that can easily convert various forms of a date to a timestamp, which is mainly: Strtotime (): Resolves the datetime description of any English text to a timestamp. ...