DateAdd函数:
function DateAdd(간격,번호 ,date){
switch(interval.toLowerCase()){
case "y": return new Date(date.setFullYear(date.getFullYear() number));
case "m": return new Date(date.setMonth(date.getMonth() number));
case "d": return new Date(date.setDate(date.getDate() number));
case "w": return new Date(date.setDate(date.getDate() 7*number));
case "h": return new Date(date.setHours(date.getHours() number));
case "n": return new Date(date.setMinutes(date.getMinutes() number));
case "s": return new Date(date.setSeconds(date.getSeconds() number));
case "l": return new Date(date.setMilliseconds(date.getMilliseconds() number));
}
}
DateDiff函数:
function DateDiff(interval,date1,date2){
var long = date2.getTime() - date1.getTime(); //상差毫秒
switch(interval.toLowerCase()){
case "y": returnparseInt(date2.getFullYear() - date1.getFullYear());
케이스 "m": returnparseInt((date2.getFullYear() - date1.getFullYear())*12 (date2.getMonth()-date1.getMonth()));
케이스 "d": returnparseInt(long/1000/60/60/24);
케이스 "w": returnparseInt(long/1000/60/60/24/7);
케이스 "h": returnparseInt(long/1000/60/60);
케이스 "n": returnparseInt(long/1000/60);
case "s": returnparseInt(long/1000);
케이스 "l": returnparseInt(long);
}
}
兼容多浏览器的datediff函数