search
HomeBackend DevelopmentPHP ProblemHow to add 1 day to time in php

php method to increase the time by 1 day: first create a PHP sample file; then use the "date('Y-m-d H:i:s',strtotime(" 1 day 1 hour 1 minute");" method The implementation time is increased by 1 day.

How to add 1 day to time in php

Recommendation: "PHP Video Tutorial"

php Current date is added Add one day to the specified date

1. Add one day to the current time? One hour?

<?php
echo "今天:",date(&#39;Y-m-d H:i:s&#39;),"<br>";
echo "明天:",date(&#39;Y-m-d H:i:s&#39;,strtotime(&#39;+1 day&#39;));
?>

The previous line outputs the current time, and the next line outputs tomorrow's time

Similarly add one Year, one hour, one minute, one month...

echo "明天:",date(&#39;Y-m-d H:i:s&#39;,strtotime(&#39;+1 day&#39;));
echo "明天:",date(&#39;Y-m-d H:i:s&#39;,strtotime(&#39;+1 hour&#39;));
echo "明天:",date(&#39;Y-m-d H:i:s&#39;,strtotime(&#39;+1 minute&#39;));
echo "明天:",date(&#39;Y-m-d H:i:s&#39;,strtotime(&#39;+1 mouth&#39;));

Here 1 day can modify parameter 1 to any number you want. Day can also be changed to year (year), month (month), hour ( hour) minute (minute), second (second) such as:

date(&#39;Y-m-d H:i:s&#39;,strtotime("+1 day +1 hour +1 minute");

can be freely combined to achieve the purpose of outputting any time

Note: This method is for trial use after 1970, and also This is the applicable scope of the timestamp.

2. Add one day to the specified time? One hour?...

echo   date("Y-m-d",strtotime("+1 month",strtotime("2012-02-04")));

The result is: 2011-03-04

echo   date("Y-m-d",strtotime("+1 week",strtotime("2011-02-04")));

The result is: 2011-02-11

echo   date("Y-m-d",strtotime("+1 day",strtotime("2011-02-04")));

The result is: 2011-02-05

Others are the same as above.

Note: This method is for 1970 It will be tried in the future, which is the scope of application of timestamps.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!