• 根据指定两个日期计算出这些时间内有多少天是周末 php程序函数代码


    $alldays = intval((sstrtotime($_POST['dayb']) - sstrtotime($_POST['daya'])) / 3600 / 24) + 1; //总天数
    $weeks = intval($alldays / 7); //纯周数
    $mdays = $alldays - 7 * $weeks; //除了纯周数外,余下那周的天数
    if($mdays == '0') {
    $_POST['psdays'] = 5 * $weeks;
    $_POST['zmdays'] = 2 * $weeks;
    } else {
    $aday = ''; //第一天是星期几,后面算出来
    $adays = date("D", sstrtotime($_POST['daya']));
    if($adays == 'Mon') {
    $aday = "1";
    } elseif($adays == 'Tue') {
    $aday = "2";
    } elseif($adays == 'Wed') {
    $aday = "3";
    } elseif($adays == 'Thu') {
    $aday = "4";
    } elseif($adays == 'Fri') {
    $aday = "5";
    } elseif($adays == 'Sat') {
    $aday = "6";
    } else {
    $aday = "7";
    }
    if($aday == '7') {
    $_POST['zmdays'] = 1 + 2 * $weeks;
    $_POST['psdays'] = $mdays - 1 + 5 * $weeks;
    } else {
    $nfanwei = 7 - $aday; //范围,从星期$aday开始(包含这一天),还有$nfanwei天就到周六
    if($mdays > $nfanwei) {
    $_POST['zmdays'] = 2 + 2 * $weeks;
    $_POST['psdays'] = $mdays - 2 + 5 * $weeks;
    } elseif($mdays == $nfanwei) {
    $_POST['zmdays'] = 1 + 2 * $weeks;
    $_POST['psdays'] = $mdays - 1 + 5 * $weeks;
    } else {
    $_POST['zmdays'] = 0 + 2 * $weeks;
    $_POST['psdays'] = $mdays + 5 * $weeks;
    }
    }
    }

    原文地址:http://www.corange.cn/archives/2011/08/3781.html
  • 相关阅读:
    DBCC Page查看表和索引数据
    sp_configure
    学习
    OpenRowSet, OpenDataSource
    sp output
    SQL Server中使用CLR调用.NET方法
    SQL Server 2005五个有用的动态管理对象
    SQL显示执行语句信息
    接规则,每三个一组编一个号
    C# winform 与 flash as 的交互通讯
  • 原文地址:https://www.cnblogs.com/zerogo/p/2133325.html
Copyright © 2020-2023  润新知