格式化日期时间戳
var translate = function(timestamp){ var ss = ['getFullYear','getMonth','getDate','getHours','getMinutes']; var sp = ['-','-',' ',':','']; var s = formatd(ss,sp,new Date(timestamp)); return s;}var formatd = function(ss, sp, d) { if (ss.length != 0) { var i = ss[0] == 'getMonth' ? (d[ss[0]]() + 1) : d[ss[0]]();//特殊处理月份 var s = (i > 9 ? i : '0' + i) + sp[0];//少于两位的前面补0 ss.shift(); sp.shift(); return s = s + formatd(ss, sp, d); } else { return ''; }}