AshKeys

Confessions and Confusions of Ashok M A. Personal and Professional Blog.

Ashok Mannolu Arunachalam, How toDateJavaScript
Back

How to convert milliseconds to date in JavaScript

Sometimes we encounter a situation to work with dates by treating them as numbers.

For instance, I had to find a quantile point from an array of dates. O_o

Using the Date.getTime() we could get the milliseconds! ^_^

js
const todayInMilliseconds = new Date().getTime();
const fromMilliseconds = new Date(todayInMilliseconds);