将毫秒转成指定的日期格式
var format = function(date, format){ var t = new Date(date); 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; } }) }
var currdate = '1369065600000';
alert(format(
new
Date().getTime(currdate),
'yyyy-MM-dd
));
远行结果:2015-05-21
相关推荐
Phplayers 2020-09-04
URML 2020-04-22
CodingNotes 2019-11-19
Marsdanding 2019-06-06
kinglee 2019-09-07
DrSmart 2015-08-10
xiaozhifree 2019-07-09
刘炳昭 2019-07-01
AI人工智能 2019-06-28
nxcjh 2019-06-29
mrsuddenflash 2013-09-09
Phplayers 2019-06-28
WindChaser 2019-06-27
pengfeibeiming 2019-06-27
自由飞翔 2014-09-09
solarLan 2019-06-26
del 2013-05-10