Home > Backend Development > PHP Tutorial > How to get yesterday, today and tomorrow's date in PHP

How to get yesterday, today and tomorrow's date in PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:04:09
Original
1597 people have browsed it

The example in this article describes the method of obtaining yesterday, today and tomorrow's date in PHP. Share it with everyone for your reference, the details are as follows:

//PHP返回昨天的日期
function get_last_date() {
 $tomorrow = mktime(0,0,0,date("m"),date("d")-1,date("Y"));
 return date("Y-m-d", $tomorrow);
}
//PHP返回今天的日期
function get_today_date() {
 $today=date("Y-m-d");
 return today;
}
//PHP返回明天的日期
function get_tomorrow_date() {
 $tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
 return date("Y-m-d", $tomorrow);
}

Copy after login

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP Date and Time Usage", "Summary of PHP Common Functions and Techniques" and " PHP object-oriented programming introductory tutorial"

I hope this article will be helpful to everyone in PHP programming.

The above introduces the method of obtaining yesterday, today and tomorrow's date in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
Latest Issues
Compare JavaScript Date objects
From 1970-01-01 08:00:00
0
0
0
Select rows grouped by date
From 1970-01-01 08:00:00
0
0
0
Hive query: Convert date timestamp to date format
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template