index.js 832 B

123456789101112131415161718192021222324
  1. var addMilliseconds = require('../add_milliseconds/index.js')
  2. /**
  3. * @category Millisecond Helpers
  4. * @summary Subtract the specified number of milliseconds from the given date.
  5. *
  6. * @description
  7. * Subtract the specified number of milliseconds from the given date.
  8. *
  9. * @param {Date|String|Number} date - the date to be changed
  10. * @param {Number} amount - the amount of milliseconds to be subtracted
  11. * @returns {Date} the new date with the milliseconds subtracted
  12. *
  13. * @example
  14. * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
  15. * var result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
  16. * //=> Thu Jul 10 2014 12:45:29.250
  17. */
  18. function subMilliseconds (dirtyDate, dirtyAmount) {
  19. var amount = Number(dirtyAmount)
  20. return addMilliseconds(dirtyDate, -amount)
  21. }
  22. module.exports = subMilliseconds