Home >Backend Development >PHP Problem >How to add time to php timestamp

How to add time to php timestamp

藏色散人
藏色散人Original
2020-08-27 10:23:333720browse

How to add time to php timestamp: First create a PHP sample file; then increase the current timestamp by one year through the "strtotime(" 1 year");" method; and finally output the increased result That’s it.

How to add time to php timestamp

Recommended: "PHP Video Tutorial"

php current timestamp increase time

php adds one year to the current timestamp

echo strtotime(" 1 year");//Return the timestamp, if you want to convert it to a general time format You also need the following function

echo date('Y-m-d H:i:s', strtotime("+1 year"));

Similarly, it can not only be year, but also day, month and day. The following code:

<?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";
?>

The above is the detailed content of How to add time to php timestamp. 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