【转】php 时间,日期计算 博客分类: php基础类 php时间计算日期计算
程序员文章站
2024-03-24 08:07:22
...
转自:http://www.oschina.net/code/snippet_4873_3145
<?php //output: 2010-1-2 //int mktime ([ int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year]]]]]] ) echo $test = date( 'Y-m-d', mktime(0,0,0,12+1,1+1,2009))."<br>"; //明天 echo $tomorrow = date( 'Y-m-d', mktime(0,0,0,date('m') ,date('d')+1,date('Y')))."<br>"; //昨天 echo $yesterday = date( 'Y-m-d',mktime(0,0,0,date('m') ,date('d')-1,date('Y')))."<br>"; //上一个月 echo $lastmonth = date( 'Y-m-d', mktime(0,0,0,date('m')-1,date('d'), date('Y')))."<br>"; //下一年 echo $nextyear = date( 'Y-m-d', mktime(0,0,0,date('m'), date('d'), date('Y')+1))."<br>"; //明天 echo $tomorrow = date('Y-m-d',strtotime ('+1 day'))."<br>"; //明天 /*echo strtotime("now"), "\n"; echo strtotime("10 September 2000"), "\n"; echo strtotime("+1 day"), "\n"; echo strtotime("+1 week"), "\n"; echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n"; echo strtotime("next Thursday"), "\n"; echo strtotime("last Monday"), "\n"; */ //使用strtotime增加日期 echo $date1 = strtotime('2010-08-09')."<br>"; echo date('Y-m-d',strtotime("+5 day",$date1)); //相应地,要增加月,年,将day改成month或year即可 ?>
推荐阅读
-
计算某时间段内所有周的时间集合 博客分类: JAVA java日期计算日期工具
-
【转】php 时间,日期计算 博客分类: php基础类 php时间计算日期计算
-
计算网页运行时间 博客分类: PHP 计算运行时间
-
Js计算时间差,天数,小时数,余数 博客分类: JAVA 乔乐共享 乔乐共享js日期时间差
-
【日期时间】批处理计算上个月最后一天的日期 博客分类: 批处理篇 BAT批处理计算上个月最后一天
-
PHP入门教程之日期与时间操作技巧总结(格式化,验证,获取,转换,计算等)
-
php 时间日期计算(加减)函数
-
PHP入门教程之日期与时间操作技巧总结(格式化,验证,获取,转换,计算等)
-
PHP日期操作类代码-农历-阳历转换、闰年、计算天数等_PHP教程
-
php计算两个日期时间差(返回年、月、日)