php string to timestamp

Guanhui
Release: 2023-02-28 21:14:01
Original
4508 people have browsed it

php string to timestamp

php string to timestamp

In PHP, you can use the "strtotime()" function to convert a string to a timestamp.

strtotime description and usage

strtotime Parses the date and time description of any string into a Unix timestamp

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

This function is expected to accept a string containing the United States A string in English date format and attempts to parse it into a Unix timestamp (number of seconds since January 1 1970 00:00:00 GMT) relative to the time given by the now parameter, or if this parameter is not provided The current system time.

This function will use the TZ environment variable (if any) to calculate the timestamp. Since PHP 5.1.0 there is an easier way to define the time zone used in all date/time functions. This process is documented on the date_default_timezone_get() function page.

strtotime parameter

time: date/time string. The correct format is explained in Date and Time Format.

now: The timestamp used to calculate the return value.

strtotime return value

Returns the timestamp if successful, otherwise returns FALSE. Prior to PHP 5.1.0, this function returned -1 on failure.



The above is the detailed content of php string to timestamp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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 [email protected]
Popular Tutorials
More>
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!