UNPKG

803 BJavaScriptView Raw
1"use strict";
2exports.getTime = getTime;
3var _index = require("./toDate.js");
4
5/**
6 * @name getTime
7 * @category Timestamp Helpers
8 * @summary Get the milliseconds timestamp of the given date.
9 *
10 * @description
11 * Get the milliseconds timestamp of the given date.
12 *
13 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14 *
15 * @param date - The given date
16 *
17 * @returns The timestamp
18 *
19 * @example
20 * // Get the timestamp of 29 February 2012 11:45:05.123:
21 * const result = getTime(new Date(2012, 1, 29, 11, 45, 5, 123))
22 * //=> 1330515905123
23 */
24function getTime(date) {
25 const _date = (0, _index.toDate)(date);
26 const timestamp = _date.getTime();
27 return timestamp;
28}