var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
month = (month < 10 ? ‘0‘ : ‘‘) + month;
var day = date.getDate();
day = (day < 10 ? ‘0‘ : ‘‘) + day;
var nowTime = year + ‘-‘ + month + ‘-‘ + day;
console.info(‘当前时间为:‘+nowTime);
本文出自 “猴子也疯狂” 博客,谢绝转载!
原文:http://1251769215.blog.51cto.com/11633863/1782839