0

i have start date and end date like below mentioned

"start_date":"2019-05-21 10:00:00", "end_date":"2019-07-31 23:59:59",

how to get a time difference between two dates in hh:mm:ss format ..i m new to react native

android_ar
  • 39
  • 5

1 Answers1

0

let start_date = "2019-05-21 10:00:00", end_date = "2019-07-31 23:59:59";

I think You are using moment to get this date time. You can find the difference using moment itself.

let difference = moment(start_date,"DD/MM/YYYY HH:mm:ss").diff(moment(end_date,"DD/MM/YYYY HH:mm:ss")); let time = moment.duration(difference)

You can format the result in any way you want using moment-duration-format.

Shan
  • 613
  • 9
  • 21