1. 程式人生 > >時間戳格式轉化

時間戳格式轉化

date != mon orm bsp cond gets nbsp date()

1.格式化成 YY-MM-DD HH:MM:SS

 1         formDate:function(time){
 2             var newDate = "";
 3             if(time !==""){
 4                 var d = new Date(time*1000),
 5                     y = d.getFullYear(),
 6                     m = d.getMonth() + 1,
 7                     dd = d.getDate(),
8 h = d.getHours(), 9 min = d.getMinutes(), 10 s = d.getSeconds(); 11 newDate = y+"-"+m+"-"+dd+" "+h+":"+min+":"+s; 12 } 13 return newDate; 14 }
formDate(1504662989) // "2017-9-6  9:56:29"

時間戳格式轉化