Home  >  Article  >  Backend Development  >  How to convert timestamp in php date

How to convert timestamp in php date

藏色散人
藏色散人Original
2020-10-23 09:34:452587browse

How to convert date to timestamp in php: First create a PHP sample file; then use the "echo strtotime("now"), "\n";" method to convert date to timestamp.

How to convert timestamp in php date

Recommended: "PHP Video Tutorial"

Use the strotime function, the code is as follows;

<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
echo strtotime("20170808 23:00:01"), "\n";
?>

How to convert timestamp in php date

Extended information:

PHP strtotime() function

1.strtotime, a function that can convert American English format time strings.

2.strtotime() can create a timestamp of a certain moment in English natural language

3. Function syntax: int strtotime(string $time[,int $now])

4. Function: Convert date and time strings in US English format into unix timestamps.

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

Statement:
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