PHP provides functions that can easily convert various forms of dates into timestamps. The main functions of this type are:
strtotime(): Convert any English text The datetime description is parsed into a timestamp.
mktime(): Get timestamp from date.
strtotime()
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 successfully Timestamp, otherwise returns FALSE.
Syntax:
1 |
|
Example:
1 2 3 4 5 6 7 8 |
|
mktime()
mktime() function is used to get a timestamp from a date , returns the timestamp successfully, otherwise returns FALSE.
Grammar:
1 |
|
Example:
1 2 3 4 |
|
For more related tutorials, please pay attention to php Chinese website.
The above is the detailed content of How to convert time to timestamp in php. For more information, please follow other related articles on the PHP Chinese website!