Get the time difference between two datetimes

前端 未结 19 2398
花落未央
花落未央 2020-11-22 05:25

I know I can do anything and some more envolving Dates with momentjs. But embarrassingly, I\'m having a hard time trying to do something that seems simple: geting the differ

19条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 06:09

    To get the difference between two-moment format dates or javascript Date format indifference of minutes the most optimum solution is

    const timeDiff = moment.duration((moment(apptDetails.end_date_time).diff(moment(apptDetails.date_time)))).asMinutes()
    

    you can change the difference format as you need by just replacing the asMinutes() function

提交回复
热议问题