# Time calculation

**URL:** <https://community.postman.com/t/time-calculation/39375>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [September 22, 2022, 1:14pm UTC](https://community.postman.com/t/time-calculation/39375 "2022-09-22T13:14:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgolyala](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sgolyala/32/13005_2.png) [@sgolyala](https://community.postman.com/u/sgolyala)\
**Post date:** [September 22, 2022, 1:14pm UTC](https://community.postman.com/t/time-calculation/39375/1 "2022-09-22T13:14:29Z")

</div>

> Here’s an outline with best practices for making your inquiry.

_My question_:  
Not sure how to calculate time difference(in secs/mins only) between two postman requests

_Details (like screenshots)_:  
I have 2 requests and I trigger them 1 after the other and log the executed time in (hh:mm:ss) and save them to env variable (using moment)

_How I found the problem_:  
In the second request I’m not sure how to calculate the time taken to execute the expected response in the second request  
1 req response : 14:20:40  
2 req response : 14:30:45  
I want to compute in the second request tests -: 2 req response - 1 req response and log it in console

_I’ve already tried_:

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [September 23, 2022, 5:04pm UTC](https://community.postman.com/t/time-calculation/39375/2 "2022-09-23T17:04:07Z")

</div>

```auto
var moment = require('moment');

var beginningTime = moment('14:20:40', 'hh:mm:ss');
var endTime = moment('14:30:45', 'hh:mm:ss');

console.log(moment(beginningTime).format("hh.mm.ss"));
console.log(moment(endTime).format("hh.mm.ss"));

console.log('Difference is ', endTime.diff(beginningTime,'seconds'), 'seconds');

```

![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/b/2ba08838e868eb6dd58010f43589084fac97e888.png)

---

<div class="post-metadata">

**Author:** ![sgolyala](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sgolyala/32/13005_2.png) [@sgolyala](https://community.postman.com/u/sgolyala)\
**Post date:** [September 26, 2022, 2:57pm UTC](https://community.postman.com/t/time-calculation/39375/3 "2022-09-26T14:57:25Z")

</div>

@michaelderekjones Thankyou very much for the help and detailed steps much appreciated 🙏
