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