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;
        }
  • 相关阅读:
    OpenSSL EVP_Digest系列函数的一个样例
    简单的函数指针使用
    写入简单的日志log
    C实现日志等级控制
    散列表
    数据结构-链表
    关于线程的几个函数
    MySQL什么时候会使用内部临时表?
    linux如何处理多连接请求?
    Centos下搭建nginx反向代理
  • 原文地址:https://www.cnblogs.com/wuchao/p/3077748.html
Copyright © 2011-2022 走看看