Moment.js isBefore function not working as expected

前端 未结 2 1344
梦谈多话
梦谈多话 2020-12-19 13:09

My console log is giving me an unexpected output.

var bool = (moment(\"2017-04-08 23:00:00\").isBefore(moment(\"2017-04-09 01:00:00\", \'day\')));
console.lo         


        
2条回答
  •  情书的邮戳
    2020-12-19 13:39

    The moment(...) argument does not accept the 'day' parameter.

    Instead, you should be calling isBefore(...) with the day parameter like so:

    moment(...).isBefore(moment(...), 'day'));
    

    More info can be found at the moment docs here.

提交回复
热议问题