Home  >  Article  >  Backend Development  >  How to get the time of day using timestamp in php

How to get the time of day using timestamp in php

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-09-29 11:52:213096browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn