Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. /**
  2. * subtractDateFromDate
  3. * Use the millisecond value insert both elements to calculate a new date.
  4. * @param d1 {Date}
  5. * @param d2 {Date}
  6. */
  7. function subtractDateFromDate(d1, d2) {
  8. return new Date(d1.getTime() - d2.getTime());
  9. }
  10. /**
  11. * addDaysToDate
  12. * Create a new Date based on the milliseconds of the first date,
  13. * adding the milliseconds for the extra days specified.
  14. * Notice that days can be a negative number.
  15. * @param d {Date}
  16. * @param days {number}
  17. */
  18. function addDaysToDate(d, days) {
  19. var oneDayInMilliseconds = 86400000;
  20. return new Date(d.getTime() + (oneDayInMilliseconds * days));
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement