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 }

 

posted @ 2015-01-21 22:31  琅琊天  阅读(1198)  评论(0编辑  收藏  举报