代码: 复主代码 代码如下: <br>var format = function(시간, 형식){ <br>var t = new Date(시간); <br>var tf = function(i){return (i < 10 ? '0' : '') i}; <BR>replace format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a){ <BR>switch(a){ <BR>case 'yyyy': <BR>return tf( t.getFullYear()); <BR>break; <BR>case 'MM': <BR>return tf(t.getMonth() 1) <BR>case 'mm': <BR> return tf(t.getMinutes()); <BR>break; <BR>case 'dd': <BR>return tf(t.getDate()) <BR>case 'HH': <BR>return tf(t.getHours()); <BR>break; <BR>case 'ss': <BR>return tf(t.getSeconds()) <BR>break; >}); <BR>}; <BR>alert(format(1396178344662, 'yyyy-MM-dd HH:mm:ss')); <BR>