/**
将一个日期往前或往后调整
@param seconds 毫秒数
*/
function resetDate(date,seconds){
var old_seconds=date.getTime();
var resetDate=new Date();
resetDate.setTime(old_seconds+seconds);
return resetDate;
}
/**
将字符串转为日期
*/
function convertString2Date(date){
return new Date(Date.parse(date.replace(/-/g,"/")));
}
/**
将日期转为字符串
*/
function convertDate2String(date){
var year=date.getFullYear();
var Month=(date.getMonth()+1).toString();
if(Month.length<2){
Month="0"+Month;
}
var day=date.getDate().toString();
if(day.length<2){
day="0"+day;
}
var h=date.getHours().toString();
if(h.length<2){
h="0"+h;
}
var m=date.getMinutes().toString();
if(m.length<2){
m="0"+m;
}
var s=date.getSeconds().toString();
if(s.length<2){
s="0"+s;
}
var time=year+"-"+Month+"-"+day+" "+h+":"+m+":"+s;
return time;
}
将一个日期往前或往后调整
@param seconds 毫秒数
*/
function resetDate(date,seconds){
var old_seconds=date.getTime();
var resetDate=new Date();
resetDate.setTime(old_seconds+seconds);
return resetDate;
}
/**
将字符串转为日期
*/
function convertString2Date(date){
return new Date(Date.parse(date.replace(/-/g,"/")));
}
/**
将日期转为字符串
*/
function convertDate2String(date){
var year=date.getFullYear();
var Month=(date.getMonth()+1).toString();
if(Month.length<2){
Month="0"+Month;
}
var day=date.getDate().toString();
if(day.length<2){
day="0"+day;
}
var h=date.getHours().toString();
if(h.length<2){
h="0"+h;
}
var m=date.getMinutes().toString();
if(m.length<2){
m="0"+m;
}
var s=date.getSeconds().toString();
if(s.length<2){
s="0"+s;
}
var time=year+"-"+Month+"-"+day+" "+h+":"+m+":"+s;
return time;
}