everyutil
Version:
A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.
15 lines (14 loc) • 430 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.unixTimestampToDate = void 0;
/**
* Converts UNIX timestamp to JS Date object.
* @author @dailker
* @param {number} ts
* @param {'s'|'ms'} [unit='ms']
* @returns {Date}
*/
function unixTimestampToDate(ts, unit = 'ms') {
return new Date(unit === 's' ? ts * 1000 : ts);
}
exports.unixTimestampToDate = unixTimestampToDate;