Moment.js Check a date is today

后端 未结 5 1328
礼貌的吻别
礼貌的吻别 2020-12-25 10:30

How do I check a date is actually today (the same date) rather than the difference between hours in a day?

I have three timestamps as examples, one is today (22/07/1

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-25 11:21

    Moment to check date is today:

    let dateStr = '2019-12-03 11:23';
    /**
     * to check above date string is today use **isSame()**
     */
    const status = moment(dateStr).isSame(moment(), 'day');  // O/P : **true**
    

提交回复
热议问题