Home > Article > Backend Development > How to convert date to timestamp in php
Convert date to timestamp in php:
Convert date to timestamp
PHP provides functions to facilitate Convert various forms of dates into timestamps. The main functions of this class are:
strtotime(): Parse the date and time description of any English text into a timestamp. mktime(): Get timestamp from date.
The strtotime() function is used to convert the date represented by the English text string into a timestamp. It is the inverse function of date() and returns the timestamp successfully, otherwise it returns FALSE.
Syntax:
int strtotime ( string time [, int now] )
The parameter time is the parsed string, which is the date represented according to the GNU date input format.
Example:
<?php echo strtotime("2009-10-21 16:00:10"); //输出 1256112010 echo strtotime("10 September 2008"); //输出 1220976000 echo strtotime("+1 day"), "<br />"; //输出明天此时的时间戳 ?>
Recommended tutorial: "php tutorial"
The above is the detailed content of How to convert date to timestamp in php. For more information, please follow other related articles on the PHP Chinese website!