index.js 605 B

123456789101112131415161718192021222324
  1. var parse = require('../parse/index.js')
  2. /**
  3. * @category Timestamp Helpers
  4. * @summary Get the milliseconds timestamp of the given date.
  5. *
  6. * @description
  7. * Get the milliseconds timestamp of the given date.
  8. *
  9. * @param {Date|String|Number} date - the given date
  10. * @returns {Number} the timestamp
  11. *
  12. * @example
  13. * // Get the timestamp of 29 February 2012 11:45:05.123:
  14. * var result = getTime(new Date(2012, 1, 29, 11, 45, 5, 123))
  15. * //=> 1330515905123
  16. */
  17. function getTime (dirtyDate) {
  18. var date = parse(dirtyDate)
  19. var timestamp = date.getTime()
  20. return timestamp
  21. }
  22. module.exports = getTime