Home > php教程 > PHP源码 > 非常全面的php日期时间运算汇总

非常全面的php日期时间运算汇总

PHP中文网
Release: 2016-05-25 17:14:30
Original
1350 people have browsed it

跳至

//output: 2010-1-2
$test = date( ‘Y-m-d’, mktime(0,0,0,12+1,1+1,2009));
//明天
$tomorrow = date( ‘Y-m-d’, mktime(0,0,0,date(‘m’) ,date(‘d’)+1,date(‘Y’)));
//昨天
$yesterday = date( ‘Y-m-d’,mktime(0,0,0,date(‘m’) ,date(‘d’)-1,date(‘Y’)));
//上一个月
$lastmonth = date( ‘Y-m-d’, mktime(0,0,0,date(‘m’)-1,date(‘d’), date(‘Y’)));
//下一年
$nextyear = date( ‘Y-m-d’, mktime(0,0,0,date(‘m’), date(‘d’), date(‘Y’)+1));
//明天
$tomorrow = date(‘Y-m-d’,strtotime (‘+1 day’)); //明天
//使用strtotime增加日期
$date1=”2010-08-09″;
echo date(‘Y-m-d’,strtotime(‘$date1 +5 day’)); //相应地,要增加月,年,将day改成month或year即可
Copy after login

                   

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 Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template