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 }
时间: 2024-11-09 01:36:18