1 function formatDateTime(date) { 2 var y = date.getFullYear(); 3 var m = date.getMonth() + 1; 4 m = m < 10 ? ('0' + m) : m; 5 var d = date.getDate(); 6 d = d < 10 ? ('0' + d) : d; 7 var h = date.getHours(); 8 h=h < 10 ? ('0' + h) : h; 9 var minute = date.getMinutes(); 10 minute = minute < 10 ? ('0' + minute) : minute; 11 var second=date.getSeconds(); 12 second=second < 10 ? ('0' + second) : second; 13 return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second; 14 }