zoukankan      html  css  js  c++  java
  • js转换日期 代码实例

    function changeDeadline() {
            var days = parseInt(document.getElementById("<%=hd_days.ClientID %>").value);
            var datetemp = document.getElementById("<%=tb_cir.ClientID %>").value
            var CurrentDate = datetemp.replace("-","/");
    
            var tarDate = new Date(CurrentDate);
            var deadline = document.getElementById("<%=tb_deadline.ClientID %>").value;
            var temp = 0;
            for (i = 1; i <= days; i++) {
                tarDate = new Date((tarDate).valueOf() + 1 * 24 * 60 * 60 * 1000);
                //alert();
                if ((tarDate.getDay() == 0) || (tarDate.getDay() == 6)) {
                    days++;
                }
            }
    
            document.getElementById("<%=tb_deadline.ClientID %>").value = tarDate.getFullYear() + "-" + (tarDate.getMonth() + 1) + "-" + tarDate.getDate();
            document.getElementById("<%=hd_deadline.ClientID %>").value = tarDate.getFullYear() + "-" + (tarDate.getMonth() + 1) + "-" + tarDate.getDate();
        }
    
        // 将日期类型转换成字符串型格式yyyy-MM-dd  
    
        function ChangeDateToString(DateIn) {
            var Year = 0;
            var Month = 0;
            var Day = 0;
    
            var CurrentDate = "";
    
            //初始化时间
            Year = DateIn.getYear();
            Month = DateIn.getMonth() + 1;
            Day = DateIn.getDate();
    
    
            CurrentDate = Year + "-";
            if (Month >= 10) {
                CurrentDate = CurrentDate + Month + "-";
            }
            else {
                CurrentDate = CurrentDate + "0" + Month + "-";
            }
            if (Day >= 10) {
                CurrentDate = CurrentDate + Day;
            }
            else {
                CurrentDate = CurrentDate + "0" + Day;
            }
    
    
            return CurrentDate;
        }
  • 相关阅读:
    Finite Difference Method with Mathematica
    评论
    The Woman in Red Is Seen as a Threat by Other Wom
    Why Does Everyone Else Appear to Be Succeeding?
    The Sorrows of Young Werther
    【洛谷P5607】无力回天 NOI2017
    【YbtOJ#532】往事之树
    【YbtOJ#582】大收藏家
    【牛客Wannafly挑战赛23 F】计数
    【YbtOJ#573】后缀表达
  • 原文地址:https://www.cnblogs.com/wuchao/p/3077748.html
Copyright © 2011-2022 走看看