php method to convert a time string into a timestamp: You can use the built-in function strtotime() to achieve this. The strtotime() function can parse the date or time description of any English text into a Unix timestamp, returning the timestamp if successful, otherwise it returns false.
PHP provides us with a large number of built-in functions, including the strtotime() function, which can parse any English text date or time description into Unix time Stamp (number of seconds since January 1 1970 00:00:00 GMT), very convenient to use.
(Video tutorial recommendation:php video tutorial)
Syntax:
strtotime(time,now);
Parameter description:
time Required. Specifies a date/time string.
now Optional. Specifies the timestamp used to calculate the return value. If this parameter is omitted, the current time is used.
Return value:
If successful, return timestamp, if failed, return FALSE.
(Related recommendations:php training)
Code sample:
"; //输出明天此时的时间戳 ?>
The above is the detailed content of How to convert time string to timestamp in php. For more information, please follow other related articles on the PHP Chinese website!