zoukankan      html  css  js  c++  java
  • 计算一段日期内的周末天数(星期六,星期日总和

    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
  • 相关阅读:
    79.Word Search
    78.Subsets
    77.Combinations
    75.Sort Colors
    74.Search a 2D Matrix
    73.Set Matrix Zeroes
    71.Simplify Path
    64.Minimum Path Sum
    63.Unique Paths II
    Docker 拉取 oracle 11g镜像配置
  • 原文地址:https://www.cnblogs.com/zerogo/p/2209075.html
Copyright © 2011-2022 走看看