MCPcopy Create free account
hub / github.com/node-modules/utility / timestamp

Function timestamp

src/date.ts:172–189  ·  view source on GitHub ↗
(t?: number | string)

Source from the content-addressed store, hash-verified

170 * Get Unix's timestamp in seconds.
171 */
172export function timestamp(t?: number | string): number | Date {
173 if (t) {
174 // convert timestamp to Date
175 // timestamp(timestampValue)
176 let v: number;
177 if (typeof t === 'string') {
178 v = Number(t);
179 } else {
180 v = t;
181 }
182 if (String(v).length === 10) {
183 v *= 1000;
184 }
185 return new Date(v);
186 }
187 // get current timestamp
188 return Math.round(Date.now() / 1000);
189}
190
191/**
192 * Parse timestamp to Date

Callers 1

parseTimestampFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…