在前台的代码中经常会用到timestamp时间戳:
1 function getCurrentTime(){ 2 var data = new Date(); 3 var vYear = data.getFullYear(); 4 var vMon = data.getMonth() + 1; 5 var vDay = data.getDate(); 6 var h = data.getHours(); 7 var m = data.getMinutes(); 8 var se = data.getSeconds(); 9 var stime=vYear+"-"+(vMon<10 ? "0" + vMon : vMon)+"-"+(vDay<10 ? "0"+ vDay : vDay)+" "+(h<10 ? "0"+ h : h)+":"+(m<10 ? "0" + m : m)+":"+(se<10 ? "0" +se : se); 10 return stime; 11 }