首页 > 代码库 > JS获取当前时间

JS获取当前时间

 1 //获取当前时间,格式:yyyy-mm-dd hh:mm:ss 2 function getNow() { 3    var now = new Date(), 4    y = now.getFullYear(), 5    month = now.getMonth(), 6    d = now.getDate(), 7    h = now.getHours(), 8    m = now.getMinutes(), 9    s = now.getSeconds();10    return (y + "-" + (month + 1) + "-" + d + " " + h + ":" + m + ":" + s);11 }

 

JS获取当前时间