Created
April 18, 2019 09:57
-
-
Save js2me/ff281c18c8e25e8741e6fa08a845e5f0 to your computer and use it in GitHub Desktop.
convert unix time to date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name unixTimeToDate | |
* | |
* @param {number} unixTimeStamp | |
* @param {boolean} fromNow = add current time to unix timestamp | |
* | |
* @returns {Date} JavaScript Date type | |
*/ | |
export const unixTimeToDate = (unixTimeStamp, fromNow = false) => | |
new Date((fromNow ? Date.now() : 0) + unixTimeStamp * 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment