1、日期格式转时间戳
1 function getTimestamp(time) 2 { 3 return Date.parse(new Date(time)); 4 }
2、时间戳转日期格式
1 function transformPHPTime(time) 2 { 3 var date = new Date(time * 1000); 4 5 Y = date.getFullYear() + '-'; 6 M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; 7 D = date.getDate() + ' '; 8 h = date.getHours() + ':'; 9 m = date.getMinutes() + ':'; 10 s = date.getSeconds(); 11 12 return Y+M+D+h+m+s; 13 }