check format of date with moment.js

前端 未结 4 596
我寻月下人不归
我寻月下人不归 2021-02-12 18:18

I am taking input from calendar in my screen which is of this type

DD-MMM-YYYY HH:mm a

but user can provide date from keyboard. Now I have to

4条回答
  •  感动是毒
    2021-02-12 18:22

    If you don't have a particular date format then you can also use Array of formats,

    moment(checked_date, [DATE_FORMAT1, DATE_FORMAT2]).format(DATE_FORMAT)
     === checked_date
    

提交回复
热议问题