Reputation: 6128
I have two Instant
objects, and need to get one Duration
object. How would I do this in JavaScript?
const start = Temporal.now.instant();
await doLongOperation();
const finish = Temporal.now.instant();
const duration = ... ?
Upvotes: 1
Views: 501
Reputation: 6128
You can use either .until()
or .since()
methods of a Temporal.Instant
object.
Until:
const duration = start.until(finish);
Since:
const duration = finish.since(start);
Upvotes: 1