check format of date with moment.js

前端 未结 4 606
我寻月下人不归
我寻月下人不归 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条回答
  •  猫巷女王i
    2021-02-12 18:39

    if it's just for checking the below is a better alternative

    moment(scope.modelValue, 'DD-MMM-YYYY HH:mm a', true).isValid()
    

提交回复
热议问题