Reference: http://stackoverflow.com/questions/1197928/how-to-add-30-minutes-to-a-javascript-date-object
function dateAdd(date, interval, units) { var ret = new Date(date); //don't change original date switch(interval.toLowerCase()) { case 'year' : ret.setFullYear(ret.getFullYear() + units); break; case 'quarter': ret.setMonth(ret.getMonth() + 3*units); break; case 'month' : ret.setMonth(ret.getMonth() + units); break; case 'week' : ret.setDate(ret.getDate() + 7*units); break; case 'day' : ret.setDate(ret.getDate() + units); break; case 'hour' : ret.setTime(ret.getTime() + units*3600000); break; case 'minute' : ret.setTime(ret.getTime() + units*60000); break; case 'second' : ret.setTime(ret.getTime() + units*1000); break; default : ret = undefined; break; } return ret; }
沒有留言:
張貼留言
留個話吧:)