• 自定义日期格式转换


    <!doctype html>  
    <html>  
    <head>  
    <meta charset="utf-8">  
    <title>show_time</title>  
    <style>
    body {  
        padding-top: 40px;  
    }  
    #main {  
        margin: auto;  
        text-align: center;  
        300px;  
        height: 200px;   
        background-color: #0CC;  
    }  
    #show_time0,#show_time {  
    300px;
    height:100px;
        color: #FFF;  
    }  
    </style>

    <script>
    //定义转换日期格式函数:Format()
    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 start_time = new Date().Format("yyyyMMdd"+"000000");

    </script>
     
    </head>  
     
    <body>  
    <div id="main">  
    <div id="show_time0" style="">
    <script>
    //将时间显示到页面中
    setTimeout("show_time0.innerHTML=start_time;",1000);
    </script>
    </div>
    </div>  
    </body>  
     
    </html>  
     

  • 相关阅读:
    Visual Studio 2008 完全卸载
    设置 Visual Studio 文件版权信息
    安装 Visual Studio 插件 Visual Assist
    下载 / 安装 Visual Studio
    Python help 函数
    Python next 函数
    Python oct 函数
    Python min 函数
    Python reload 函数
    numpy中matrix的特殊属性
  • 原文地址:https://www.cnblogs.com/lovehansong/p/10418492.html
Copyright © 2020-2023  润新知