Moment js convert milliseconds into date and time
Asked Answered
C

3

78

I have current time in milliseconds as - 1454521239279

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

Celina answered 3/2, 2016 at 17:42 Comment(1)
momentjs.com/#format-datesNatatory
D
187

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")
Declassify answered 3/2, 2016 at 17:47 Comment(4)
Dude, you just saved me. Have been looking for answer from last 2 hours, nothing worked except this :)Lorettelorgnette
in my response_date_string I am getting 616090400000 and i need to show date with time which should be in this case 2021-03-18 18:00:00 , any idea ?Your
In the current version of moment these methods throw a deprecation warning.Oxidize
It seems doing a parseInt("123123123312") suppresses the warning.Oxidize
C
3

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

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

OR

new Date(1591074937 * 1000)
Chaconne answered 3/6, 2020 at 16:56 Comment(0)
G
0

just do this moment(1662969163000).format("DD/MM/YYYY")

Gatecrasher answered 23/9, 2022 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.