How to convert date to timestamp in php

Guanhui
Release: 2023-02-28 22:14:01
Original
4534 people have browsed it

How to convert date to timestamp in php

How to convert date to timestamp in php

In php, you can convert date to time by using the function "strtotime()" stamp.

strtotime() definition and usage

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

strtotime() function parses any string datetime description into a Unix timestamp (since January 1 1970 00:00 :00 GMT).

Note: If the year representation uses a two-digit format, values 0-69 are mapped to 2000-2069 and values 70-100 are mapped to 1970-2000.

Note: Please note that for dates in m/d/y or d-m-y format, if the delimiter is a slash (/), the American m/d/y format is used. If the delimiter is a dash (-) or a dot (.), the European d-m-y format is used. To avoid potential errors, you should use YYYY-MM-DD format whenever possible or use the date_create_from_format() function.

strtotime() parameters

Parameters
Description
time
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.

strtotime() return value

Returns the timestamp on success, and returns FALSE on failure.

Recommended tutorial: "PHP Tutorial"

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!