自定义日期时间格式
function dateToString(now){
var year = now.getFullYear();
var month =toTwo( now.getMonth()+1 );
var d =toTwo( now.getDate() );
var h = toTwo( now.getHours() ) ;
var m = toTwo( now.getMinutes() );
var s = toTwo( now.getSeconds() );
return year+"-"+month+"-"+d + " " + h + ":" + m + ":" +s;
}
function toTwo( str ){
return str<10 ? "0"+str : str;
}
将字符串转成日期时间格式
function stringToDate( str ){
return new Date( str );
}
时间差函数
function diff(start,end){
return (end.getTime()-start.getTime())/1000;
}