Home  >  Article  >  Backend Development  >  How to get yesterday's, today's and tomorrow's dates in PHP_php tips

How to get yesterday's, today's and tomorrow's dates in PHP_php tips

WBOY
WBOYOriginal
2016-05-16 19:59:072454browse

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);
}

Readers who are interested in more PHP-related content can check out the special topics on 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.

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