Moment js convert milliseconds into date and time

JavascriptMomentjs

Javascript Problem Overview


I have current time in milliseconds as - 1454521239279

How do I convert it to 03 FEB 2016 and time as 11:10 PM ?

Javascript Solutions


Solution 1 - Javascript

Moment parser

moment(1454521239279).format("DD MMM YYYY hh:mm a") //parse integer
moment("1454521239279", "x").format("DD MMM YYYY hh:mm a") //parse string

Moment unix method

moment.unix(1454521239279/1000).format("DD MMM YYYY hh:mm a")

Solution 2 - Javascript

If you have 1o digit 1591074937 then you can convert like this.

moment(1591074937*1000).format("DD MMM YYYY")

OR

new Date(1591074937 * 1000)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAjeyView Question on Stackoverflow
Solution 1 - JavascriptEnver DzhaparoffView Answer on Stackoverflow
Solution 2 - JavascriptAnkit Kumar RajpootView Answer on Stackoverflow