Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moment js convert milliseconds into date and time

I have current time in milliseconds as - 1454521239279

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

like image 228
Ajey Avatar asked Feb 03 '16 17:02

Ajey


People also ask

How do you convert milliseconds to date and time?

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.

How do you convert milliseconds to moments?

To convert milliseconds into date and time with Moment. js and JavaScript, we use the format method. const dateTime = moment(1454521239279).

How do I get time from moment to dateTime?

The moment(). hour() Method is used to get the hours from the current time or to set the hours. moment(). hours();

How do you convert moments to dates?

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.


1 Answers

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") 
like image 115
Enver Dzhaparoff Avatar answered Sep 22 '22 06:09

Enver Dzhaparoff