zoukankan      html  css  js  c++  java
  • js计算日期天数差-2013-9-26

    function daymath(sdate, edate) {
                var startdate = sdate;
                var enddate = edate;
                if (startdate == "" || enddate == "") {
                    return;
                }
                startdate = startdate.replace(/-/g, "/");
                enddate = enddate.replace(/-/g, "/");
                var hour = (new Date(enddate) - new Date(startdate)) / 1000 / 60 / 60 / 24;
                var inthour = parseInt(hour);
                if (inthour <= 0) {
                    $("#day").val("");
                    return;
                }
                var h = hour.toString();
                var hflot = 0;
                var day = 0;
                if (h.indexOf('.') > 0) {
                    hflot = parseInt(h.substring(h.indexOf('.') + 1, (h.indexOf('.') + 2)));
                }
                if (hflot > 5) {
                    day = inthour + 1;
                }
                if (hflot > 0 && hflot < 5) {
                    day = inthour + 0.5;
                }
                else {
                    day = inthour;
                }
                return day;
            }

  • 相关阅读:
    12-14面向对象--抽象基类、接口、委托
    关于 try catch catch
    C# using 三种使用方式
    互斥锁(Mutex)
    C#中Monitor类、Lock关键字和Mutex类
    System.Data.SQLite
    Dictionary<TKey, TValue> 类
    AttributeTargets 枚举
    C# is和as操作符
    合并委托(多路广播委托)
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3341824.html
Copyright © 2011-2022 走看看