计算一段日期内的周末天数(星期六,星期日总和
2011-08-29 08:58
393 查看
function get_weekend_days($start_date,$end_date){
if (strtotime($start_date) > strtotime($end_date)) list($start_date, $end_date) = array($end_date, $start_date);
$start_reduce = $end_add = 0;
$start_N = date('N',strtotime($start_date));
$start_reduce = ($start_N == 7) ? 1 : 0;
$end_N = date('N',strtotime($end_date));
in_array($end_N,array(6,7)) && $end_add = ($end_N == 7) ? 2 : 1;
$days = abs(strtotime($end_date) - strtotime($start_date))/86400 + 1;
return floor(($days + $start_N - 1 - $end_N) / 7) * 2 - $start_reduce + $end_add;
}
echo get_weekend_days(date("Y-m-d H:i:s",time()),"2011-8-21 15:23:48");
原文地址:http://www.corange.cn/archives/2011/08/3782.html
if (strtotime($start_date) > strtotime($end_date)) list($start_date, $end_date) = array($end_date, $start_date);
$start_reduce = $end_add = 0;
$start_N = date('N',strtotime($start_date));
$start_reduce = ($start_N == 7) ? 1 : 0;
$end_N = date('N',strtotime($end_date));
in_array($end_N,array(6,7)) && $end_add = ($end_N == 7) ? 2 : 1;
$days = abs(strtotime($end_date) - strtotime($start_date))/86400 + 1;
return floor(($days + $start_N - 1 - $end_N) / 7) * 2 - $start_reduce + $end_add;
}
echo get_weekend_days(date("Y-m-d H:i:s",time()),"2011-8-21 15:23:48");
原文地址:http://www.corange.cn/archives/2011/08/3782.html
相关文章推荐
- 计算一段日期内的周末天数(星期六,星期日总和)(
- 计算一段日期内的周末天数的php代码(星期六,星期日总和)
- 计算一段日期内的周末天数(星期六,星期日总和
- 计算一段日期内的周末天数(星期六,星期日总和
- 计算一段日期内的周末天数(星期六,星期日总和)(
- 计算一段日期内的周末天数(星期六,星期日总和
- 计算一段日期内的周末天数的php代码(星期六,星期日总和)
- 计算一段日期内的周末天数(星期六,星期日总和)
- 计算一段日期内的周末天数的php代码(星期六,星期日总和)
- java计算两个日期之前的天数(工作日),排除节假日和周末
- 计算两个日期之间周末天数in php
- PHP计算指定时间段内周末天数(星期日天数)、双休天数、总工作日天数
- PHP计算指定时间段内周末天数(星期日天数)、双休天数、总工作日天数
- 强大的PLSQL - 计算两个日期之间的工作日天数-除去(周末和公共假日
- 计算两个日期相差的工作天数,过滤了周末双休天数
- 计算两个日期之间的间隔天数、周末天数、以及为当年的哪一周
- java计算两个日期之前的天数实例(排除节假日和周末)
- 如何在计算一年内日期间隔时减去星期六和星期日
- 计算两个日期之间相差的天数
- 华为OJ中级-计算日期到天数转换