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

192
Views
How to add minutes to a string which holds time In HH:MM AM/PM format

I have my string which contains time like var time = '11:50 AM'

I try to add 10 minutes to my string, so it should be like 12:00 PM, the both minutes and (AM/PM) has to be changed.

How to perform this kind of operations? In JavaScript.

as I'm new to the technology, please help me out.

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

0

Here's one way to do it in a few easy to read steps.

However, working with dates in vanilla JavaScript can be tricky. It might be worth looking into a library like Moment.js which makes working with dates/times easier.

// string
var timeString = '11:50';
// create proper date with the string
var date = new Date('2022-01-01T' + timeString+ ':00Z');
// add 10 minutes
var newDate = new Date(date.getTime() + 10*60000);
// split the new string
var newDateSplit = newDate.toTimeString().split(':');
// get hour and minutes from split date
var newTimeString = newDateSplit[0] + ':' + newDateSplit[1];

console.log('original time: ' + timeString)
console.log('new time: ' + newTimeString)

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!