Home > Article > Backend Development > How to get the time of day using timestamp in php
Implementation function: Get the timestamp of a certain date, or get the PHP timestamp of a certain time.
strtotime can parse the date and time description of any English text into a Unix timestamp. We combine mktime() or date() to format the date and time to obtain the specified timestamp to achieve the required date and time.
strtotime parses the date and time description of any English text into a Unix timestamp [convert system time into a unix timestamp]
Related recommendations: "php introductory tutorial"
1. Get the unix timestamp strtotime("2009-1-22") of the specified date. The example is as follows:
echo strtotime(“2009-1-22”)
Result:
1232553600
Instructions: Return to 2009 January 22nd 0:00:00 seconds timestamp
2. Get the English text date and time, the example is as follows:
For comparison, use date to convert the current timestamp and the specified timestamp into system time.
Current time:
echo date(”Y-m-d H:i:s”,time())
Result:
2009-01-22 09:40:25
The above is the detailed content of How to get the time of day using timestamp in php. For more information, please follow other related articles on the PHP Chinese website!