1 $time1 = strtotime('2014-02-04'); // 自动为00:00:00 时分秒 两个时间之间的年和月份
2 $time2 = strtotime('2015-02-06');
3
4 $monarr = array();
5 $monarr[] = '2014-02'; // 当前月;
6 while( ($time1 = strtotime('+1 month', $time1)) <= $time2){
7 $monarr[] = date('Y-m',$time1); // 取得递增月;
8 }
9
10 print_r($monarr);
1 <?php
2 //今天与2008年9月9日相差多少天
3 $Date_1 = date("Y-m-d");
4 $Date_2 = "2008-10-11";
5 $d1 = strtotime($Date_1);
6 $d2 = strtotime($Date_2);
7 $Days = round(($d2-$d1)/3600/24);
8 echo "今天与2008年10月11日相差" . $Days . "天";
9 ?>
1 <?php
2 function prDates($start,$end){ // 两个日期之间的所有日期
3 $dt_start = strtotime($start);
4 $dt_end = strtotime($end);
5 while ($dt_start<=$dt_end){
6 echo date('Y-m-d',$dt_start)."\n";
7 $dt_start = strtotime('+1 day',$dt_start);
8 }
9 }
10 prDates('2005-02-01','2005-02-05');
11
12 ?>