How to convert date to timestamp in php

王林
Release: 2023-03-03 13:26:01
Original
2566 people have browsed it

The way PHP converts dates into timestamps is: You can use the strtotime() function to achieve this. This function can parse any string datetime description into a Unix timestamp, returning FALSE on failure. The specific usage method is: [strtotime("2009-10-21 16:00:10")].

How to convert date to timestamp in php

strtotime() function parses any string datetime description into a Unix timestamp (number of seconds since January 1 1970 00:00:00 GMT ), returns the timestamp if successful, and returns FALSE if failed.

(Recommended tutorial:php tutorial)

Grammar format:

int strtotime ( string $time [, int $now = time() ] )
Copy after login

Parameter description:

  • time is 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.

Code implementation:

";//输出明天此时的时间戳 ?>
Copy after login

The above is the detailed content of How to convert date to 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!