Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
postman: How to add minutes to a dateTime while looping with JS?

I am trying to add 15 mins to a dateTime(2100-01-04T08:00:00) while looping. For each run I want to add 15 minutes , so it would be 2100-01-04T08:15:00 , 2100-01-04T08:30:00 and so on… I know I can do the below: var moment = require('moment'); moment().add(15, 'minutes').toISOString(); But this will add 15 minutes to the current moment time but I want to add 15 minutes to 2100-01-04T08:00:00.

Is this possible in postman?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can achieve this without using any third party libraries like momentJs. The default javascript Date object has methods for getting the minutes property for a date object - getMinutes() and also another method for updating this minutes property - setMinutes(). Combining them both, you can achieve your required answer.

let x = new Date('2100-01-04T08:00:00') 
for(let i = 0 ; i < 5; i ++){
  x.setMinutes(x.getMinutes()+15);
  console.log(x)
}

P.S, remove 'postman' from your question. It has nothing to do with the problem you are facing.

about 4 years ago · Juan Pablo Isaza Report

0

You can easily create an addMinutes() function to add a number of minutes to a date, you can then use a while loop to loop until a specified end date is reached.

In the example below, we'll add 15 minutes to the date until the end date is reached.

function addMinutes(date, minutes) {
    let newDate = new Date(date);
    newDate.setMinutes(newDate.getMinutes() + minutes);
    return newDate;
}

let date = new Date('2100-01-04T08:00:00');
let endDate = new  Date('2100-01-04T09:00:00');

let deltaMinutes = 15;
while (date <= endDate) {
    console.log(date.toLocaleString('en-US'));
    date = addMinutes(date, 15);
}
.as-console-wrapper { max-height: 100% !important; }

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!