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

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

PHP中文网
PHP中文网Original
2016-05-25 17:14:301350browse

跳至

//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即可

                   

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