标签:时间类 code parse 时间戳 second int for return ret
1 //事件戳转换 2 function add0(m){return m<10?‘0‘+m:m } 3 function formatDate(timestamp) 4 { 5 //timestamp是整数,否则要parseInt转换 6 var time = new Date(timestamp); 7 var y = time.getFullYear(); 8 var m = time.getMonth()+1; 9 var d = time.getDate(); 10 var h = time.getHours(); 11 var mm = time.getMinutes(); 12 var s = time.getSeconds(); 13 return y+‘-‘+add0(m)+‘-‘+add0(d)+‘ ‘+add0(h)+‘:‘+add0(mm)+‘:‘+add0(s); 14 }
标签:时间类 code parse 时间戳 second int for return ret
原文地址:http://www.cnblogs.com/sunnyny/p/6852442.html