首页 > 其他 > 详细

获取当前时间 年月日时分秒

时间:2021-07-01 11:59:10      阅读:21      评论:0      收藏:0      [点我收藏+]
  var date = new Date();
    var seperator1 = "-";

    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var hour = date.getHours();
    var minutes = date.getMinutes();
    var seconds = date.getSeconds();
    var strDate = date.getDate();

    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    if (hour >= 0 && hour <= 9) {
        hour = "0" + hour;
    }
    if (minutes >= 0 && minutes <= 9) {
        minutes = "0" + minutes;
    }
    if (seconds >= 0 && seconds <= 9) {
        seconds = "0" + seconds;
    }
    var curtimestart =  year + seperator1 + month + seperator1 + strDate  + " " + 00 + ":" + 00 + ":" + 00;
    var curtimeend = year + seperator1 + month + seperator1 + strDate + " " + hour + ":" + minutes + ":" + seconds;

转载于:https://www.cnblogs.com/xzybk/p/11547354.html

获取当前时间 年月日时分秒

原文:https://www.cnblogs.com/xxshen/p/14957414.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!