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

How to get the time of day using timestamp in php

爱喝马黛茶的安东尼
Release: 2023-02-25 15:02:02
Original
3153 people have browsed it

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”)
Copy after login

Result:

1232553600
Copy after login

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())
Copy after login

Result:

2009-01-22 09:40:25
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template