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;
        }
  • 相关阅读:
    ClipboardJS实现将页面内容复制到剪贴板
    全文索引FULLTEXT 的使用
    [1].Array.diff
    Leetcode——Queue队列
    Matplotlib——scatter散点图
    Matplotlib的一些小细节——tick能见度
    Matplotlib的一些小细节——Annotation标注
    Matplotlib的一些小细节——Legend图例
    Matplotlib基本知识(figure & axes
    锁升级简记
  • 原文地址:https://www.cnblogs.com/wuchao/p/3077748.html
Copyright © 2011-2022 走看看