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


    简介:这是根据指定两个日期计算出这些时间内有多少天是周末 php程序函数代码的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。

    class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=343705' scrolling='no'>$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

    爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

    http://biancheng.dnbcw.info/php/343705.html pageNo:5
  • 相关阅读:
    ES6之Promise用法详解
    Vue项目部署问题及解决方案
    Vue---导航守卫使用方法详解
    深入理解Vue的生命周期
    Bootstrap中datetimepicker日期控件1899年问题解决
    基于Vue-cli 快速搭建项目
    Vue-router的基本用法
    js保留两位小数方法总结
    Vue---父子组件之间的通信
    Vue---自定义组件
  • 原文地址:https://www.cnblogs.com/ooooo/p/2241982.html
Copyright © 2020-2023  润新知