Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

28 строки
873 B

  1. import getTime from '../getTime/index.js';
  2. import requiredArgs from '../_lib/requiredArgs/index.js';
  3. /**
  4. * @name getUnixTime
  5. * @category Timestamp Helpers
  6. * @summary Get the seconds timestamp of the given date.
  7. *
  8. * @description
  9. * Get the seconds timestamp of the given date.
  10. *
  11. * ### v2.0.0 breaking changes:
  12. *
  13. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  14. *
  15. * @param {Date|Number} date - the given date
  16. * @returns {Number} the timestamp
  17. * @throws {TypeError} 1 argument required
  18. *
  19. * @example
  20. * // Get the timestamp of 29 February 2012 11:45:05 CET:
  21. * var result = getUnixTime(new Date(2012, 1, 29, 11, 45, 5))
  22. * //=> 1330512305
  23. */
  24. export default function getUnixTime(dirtyDate) {
  25. requiredArgs(1, arguments);
  26. return Math.floor(getTime(dirtyDate) / 1000);
  27. }