zoukankan      html  css  js  c++  java
  • js获取当前时间

    /**
         * getNowFormatDate 获取当前时间
         * @param msec 毫秒值
         */
        getNowFormatDate :function(msecVal){
            if(msecVal){
                var now = new Date(msecVal); //毫秒值转为完整时间
            }else{
                var now = new Date(); //完整时间
            };
            var month = now.getMonth() + 1; //当前月份
            var day = now.getDate();        //当前天
            var Hours = now.getHours();     //当前时
            var Minutes = now.getMinutes(); //当前分
            var Seconds = now.getSeconds(); //当前秒
            if(month >= 1 && month <= 9){   //
                month = "0" + month;
            };
            if(day >= 0 && day <= 9){ //
                day = "0" + day;
            };
            if(Hours >= 0 && Hours <= 9){ //
                Hours = "0" + Hours;
            };
            if(Minutes >= 0 && Minutes <= 9){ //
                Minutes = "0" + Minutes;
            };
            if(Seconds >= 0 && Seconds <= 9){ //
                Seconds = "0" + Seconds;
            };
            var currentdate = now.getFullYear() + "-" + month + "-" + day + " " + 
                Hours + ":" + Minutes + ":" + Seconds;
            return currentdate;
        },
  • 相关阅读:
    逼哥
    作业
    malloc的底层实现
    docker基本使用
    对mudo中noncopyable类的理解
    整理
    替换war包中的文件
    SpringMVC(1):SpringMVC入门
    MySQL(5):安装MySQL
    MySQL(4):卸载MySQL
  • 原文地址:https://www.cnblogs.com/hjbky/p/9102363.html
Copyright © 2011-2022 走看看