Home > Backend Development > PHP Problem > How to convert date to timestamp in php

How to convert date to timestamp in php

hzc
Release: 2023-03-01 13:54:01
Original
2436 people have browsed it

How to convert date to timestamp in php

Convert date to timestamp in php:

Convert date to timestamp

PHP provides functions to facilitate Convert various forms of dates into timestamps. The main functions of this class are:

strtotime(): Parse the date and time description of any English text into a timestamp. mktime(): Get timestamp from date.

The strtotime() function is used to convert the date represented by the English text string into a timestamp. It is the inverse function of date() and returns the timestamp successfully, otherwise it returns FALSE.

Syntax:

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

The parameter time is the parsed string, which is the date represented according to the GNU date input format.

Example:

<?php
echo strtotime("2009-10-21 16:00:10");
//输出 1256112010
echo strtotime("10 September 2008");
//输出 1220976000
echo strtotime("+1 day"), "<br />";
//输出明天此时的时间戳
?>
Copy after login

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:
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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template