Convert 12 hour (AM/PM) string to 24 Date object using moment js

后端 未结 8 1063
轻奢々
轻奢々 2021-02-01 01:26

I have a output resulting from a timepicker giving 12 hour format of time.

Eg : \"1:45 AM (or) \"12:15 PM\" as **string**

Is there a way to par

8条回答
  •  野的像风
    2021-02-01 01:46

    I know that this answer is not for the question (actually it is for the opposite case), but I will put it for completeness and if someone (like me) was looking for it.
    In case you want to convert from the 24 Hour system to 12 Hour system then you could use the following

    return moment("13", ["HH"]).format("hh A");
    

    the previous code will produce the result 1 PM

提交回复
热议问题