码迷,mamicode.com
首页 > Web开发 > 详细

JS获取当前时间

时间:2015-01-22 00:02:51      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

 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获取当前时间

标签:

原文地址:http://www.cnblogs.com/wanshi1989/p/4240317.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!