时间戳和时间转换
// 时间戳转化为时间
function getDT (unix) { var time = new Date(unix*1000); var y = time.getFullYear(); var m = time.getMonth()+1; var d = time.getDate(); var h = time.getHours() < 10 ? '0' + time.getHours() : time.getHours(); var mm = time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes(); var s = time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds(); return y+'-'+m+'-'+d+' '+h+':'+mm+':'+s; },
// 时间转化为时间戳
function datetimeToUnix(datetime){ if(datetime=="") { return 0; } var tmp_datetime = datetime.replace(/:/g,'-'); tmp_datetime = tmp_datetime.replace(/ /g,'-'); var arr = tmp_datetime.split("-"); var now = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5])); return parseInt(now.getTime()/1000); }