Moment.js - tomorrow, today and yesterday

后端 未结 12 2212
悲哀的现实
悲哀的现实 2021-01-30 00:21

I\'d like the moment().fromNow() functionality, but when the date is close it is too precise - ex. I don\'t want it to show \'in 3 hours\' but \'today\' - so basica

12条回答
  •  自闭症患者
    2021-01-30 01:17

    You can use this:

    
    const today     = moment();
    
    const tomorrow  = moment().add(1, 'days');
    
    const yesterday = moment().subtract(1, 'days');
    
    

提交回复
热议问题