0

First, I refer : Get the time difference between two datetimes

Then, it doesn't work as I'm using iso time format.

var now = '2014-12-12T09:30:00.0000000Z';
var then = '2014-12-12T11:00:00.0000000Z';
var timeDuration = moment.utc(moment(now)).diff(moment(then)).format("HH:mm:ss");
Community
  • 1
  • 1
baker
  • 73
  • 1
  • 11

1 Answers1

0

Try this:

var format = "YYYY-MM-DD HH:mm Z";
var now = '2014-12-12T09:30:00.0000000Z';
var then = '2014-12-12T11:00:00.0000000Z';
var timeDuration = moment(moment.utc(moment(then, format)).diff(moment(now, format))).format("HH:mm:ss");
print(timeDuration);
"01:30:00"
Gianfranco P.
  • 10,049
  • 6
  • 51
  • 68