function format(time) { var t = new Date(time); var format = "yyyy-MM-dd HH:mm:ss"; var tf = function (i) { return (i < 10 ? '0' : '') + i }; return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) { switch (a) { case 'yyyy': return tf(t.getFullYear()); break; case 'MM': return tf(t.getMonth() + 1); break; case 'mm': return tf(t.getMinutes()); break; case 'dd': return tf(t.getDate()); break; case 'HH': return tf(t.getHours()); break; case 'ss': return tf(t.getSeconds()); break; } }) }
js格式化显示时间
猜你喜欢
转载自blog.csdn.net/zhangdongnihao/article/details/82151661
今日推荐
周排行