Home>Article>Backend Development> How to get the time in a few days in php

How to get the time in a few days in php

藏色散人
藏色散人 Original
2021-06-01 09:24:54 4641browse

php method to get the time in a few days: first create a PHP sample file; then use "date("Y-m-d H:i:s",strtotime("3 day"));" to get the time in 3 days Time is enough.

How to get the time in a few days in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php method to get the time and date after N days

Example 1: php gets the time and date after 3 days

Code:

Output result:

2019-11-07 23:23:25 2019-11-10 23:23:25

Example 2: php gets the time after n days Date function

Function code:

Function call:

Supplementary instructions:

Flexibly use PHP’s strtotime(), you can also get The time and date are N hours before, N hours after, one week ago, one month after, etc. of the current time.

Example:

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to get the time in a few days 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