获取系统当前时间 并格式化

          var date1 = new Date();
          var time1 = date1.getTime();
          var timeChuo1 = new Date(time1);
          var y = timeChuo1.getFullYear();
          var m = timeChuo1.getMonth()+1;
          var d = timeChuo1.getDate();
          var h = timeChuo1.getHours();
          var mm = timeChuo1.getMinutes();
          var s = timeChuo1.getSeconds();
          var startDate = y+'-'+m+'-'+d+' '+h+':'+mm+':'+s
          if(startDate == 'NaN-NaN-NaN NaN:NaN:NaN'){
              startDate = ''
          }else{
            startDate = y+'-'+m+'-'+d+' '+h+':'+mm+':'+s
          }
          if(startDate == '1970-1-1 8:0:0'){
              startDate = ''
          }

你可能感兴趣的:(获取系统当前时间 并格式化)