zoukankan      html  css  js  c++  java
  • JavaScript格式化日期输出

     JavaScript Code 
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    <script>
        window.onload = function(){  
            Date.
    prototype.Format = function (fmt) {                    
            
    var o = {
                    
    "M+"this.getMonth() + 1,                      //月份 
                    "d+"this.getDate(),                           //日 
                    "H+"this.getHours(),                          //小时 
                    "m+"this.getMinutes(),                        //分 
                    "s+"this.getSeconds(),                        //秒 
                    "q+": Math.floor((this.getMonth() + 3) / 3),    //季度 
                    "S"this.getMilliseconds()                     //毫秒 
            };
            
    if (/(y+)/.test(fmt)) 
                fmt = fmt.replace(RegExp.$1, (
    this.getFullYear() + "").substr(4 - RegExp.$1.length));
            
    for (var k in o)
            
    if (new RegExp("(" + k + ")").test(fmt)) 
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 
    1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            
    return fmt;
            }
        
            
    var currenttime1 = new Date().Format("yyyy-MM-ddTHH:mm:ss");  
            
    var pselstart = document.getElementById("starttime");  
            pselstart.value = currenttime1;
            
    var currenttime2 = new Date().Format("yyyy-MM-ddTHH:mm:ss");  
            
    var pselend = document.getElementById("endtime");  
            pselend.value = currenttime2;   
        }
    </script>

  • 相关阅读:
    关于带权并查集
    Connections in Galaxy War ZOJ
    Supermarket POJ
    并查集判树 poj 1308
    最长异或值路径【字典树应用】
    最大异或对
    trie字典树【模板题】
    UVA536 二叉树重建 Tree Recovery
    UVA1584环状序列 Circular Sequence
    【CodeForces 622F】The Sum of the k-th Powers
  • 原文地址:https://www.cnblogs.com/MakeView660/p/7410215.html
Copyright © 2011-2022 走看看