Skip to content

Convert epoch timestamp to JavaScript date

To convert epoch value to a JavaScript date object, we need to multiply it with 1000 to get milliseconds equivalent of the epoch timestamp and pass it to Date() constructor to get JavaScript date.

Advertisements
var myDate = new Date(1601528702*1000);
console.log(myDate.toLocaleString()); // 01/10/2020, 10:35:02
See also  Fibonacci Number - Leetcode Challenge - Java Solution

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.