How to parse ISO 8601 into date and time format using Moment js in Javascript?

后端 未结 2 1927
你的背包
你的背包 2020-12-14 01:35

I am currently using Moment js to parse an ISO 8601 string into date and time, but it is not working properly. What am I doing wrong? And I would take any other easier solut

2条回答
  •  無奈伤痛
    2020-12-14 02:10

    There's two parts to the moment operation: reading the date/time in, and spitting it back out. You've got the first part:

    moment("2011-04-11T10:20:30Z")
    

    but then you need to call an output function, eg:

    moment("2011-04-11T10:20:30Z").format('YYYY-MM-DD h:mm:ss a')
    

提交回复
热议问题