-2

How to convert time from milliseconds to date time in javascript. I need to convert from milliseconds to below mentioned format.

format : 20-10-1994 06:00:00

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • [JavaScript `Date` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) – Pointy Feb 28 '18 at 17:15
  • 1
    Please [**search thoroughly**](/help/searching) before posting. Getting a date from milliseconds-since-the-Epoch and every conceivable date formatting question has been asked and answered (including without using libs). – T.J. Crowder Feb 28 '18 at 17:17
  • see the Answers here : https://stackoverflow.com/a/9763769/7465452 - – The Doctor Feb 28 '18 at 17:19

1 Answers1

0

You can use it that way.

var d = new Date(milliseconds);
var myDate = d.getDate() + "-" + (d.getMonth() + 1) + "-" + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();

Reference:

https://www.w3schools.com/jsref/jsref_obj_date.asp

https://www.w3schools.com/js/js_date_methods.asp