Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Convert Milliseconds to Date in JS?

My scenario is to convert the data of milliseconds to a date format. I have tried a lot as here http://jsbin.com/jeququ/1/ but it is only working for a limited milliseconds value, and fails if the value is high. I am looking to replicate the functionality as http://www.ruddwire.com/handy-code/date-to-millisecond-calculators/#.VJAp9lWUe1R

Milliseconds Since : Thu Jan 01 1970 05:30:00 GMT+0530

like image 688
user3592479 Avatar asked Dec 16 '14 13:12

user3592479


People also ask

What is getTime in JavaScript?

getTime() The getTime() method returns the number of milliseconds since the ECMAScript epoch. You can use this method to help assign a date and time to another Date object.

Is JavaScript time in milliseconds?

JavaScript Date getTime()getTime() returns the number of milliseconds since January 1, 1970 00:00:00.

How do you convert milliseconds to dates in Excel?

If you need milliseconds, you need to add a further multiplication / division by 1000. For example, converting from epoch time (milliseconds) to a date would be "=((((A1/1000)/60)/60)/24)+DATE(1970,1,1)".


1 Answers

This should work:

var d = new Date(milliseconds);
like image 179
Sagar Koshti Avatar answered Oct 01 '22 11:10

Sagar Koshti