I have current time in milliseconds as - 1454521239279
How do I convert it to 03 FEB 2016 and time as 11:10 PM ?
Use the Date() constructor to convert milliseconds to a date, e.g. const date = new Date(timestamp) . The Date() constructor takes an integer value that represents the number of milliseconds since January 1, 1970, 00:00:00 UTC and returns a Date object.
To convert milliseconds into date and time with Moment. js and JavaScript, we use the format method. const dateTime = moment(1454521239279).
The moment(). hour() Method is used to get the hours from the current time or to set the hours. moment(). hours();
Date Formatting Date format conversion with Moment is simple, as shown in the following example. moment(). format('YYYY-MM-DD'); Calling moment() gives us the current date and time, while format() converts it to the specified format.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With