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

How to add time to php timestamp

藏色散人
Release: 2023-03-05 10:12:01
Original
3697 people have browsed it

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"));
Copy after login

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";
?>
Copy after login

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!

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