jquery获取当前系统时间--已解决

xiaoxiao2021-02-28  99

//获取当前时间 function nowtime(){  var myDate = new Date(); //获取当前年 var year=myDate.getFullYear(); //获取当前月 var month=myDate.getMonth()+1; //获取当前日 var date=myDate.getDate(); var h=myDate.getHours();       //获取当前小时数(0-23) var m=myDate.getMinutes();     //获取当前分钟数(0-59) var s=myDate.getSeconds(); var now=year+'-'+p(month)+"-"+p(date)+" "+p(h)+':'+p(m)+":"+p(s); return now; } //转换格式 function p(s) {  return s < 10 ? '0' + s: s;

}

alert(nowtime());  //时间格式:2017-8-31 11:36:45

转载请注明原文地址: https://www.6miu.com/read-28136.html

最新回复(0)