Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7680283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:04:47+00:00 2026-05-31T18:04:47+00:00

I have a Javascript Date object equal to 00:30 and when doing: date.setMinutes(date.getMinutes() +

  • 0

I have a Javascript Date object equal to 00:30 and when doing:

date.setMinutes(date.getMinutes() + 30);

causes the date object to equal 00:00.

Does anyone know why this is happening?

Here is where the code is being used:

for (var i = openTime; i <= closeTime; i.setMinutes(i.getMinutes() + timeIncrement)) {
  var time = i.getHours() + (i.getHours() == 0 ? '0' : '') + ':' + i.getMinutes() + (i.getMinutes() == 3 || i.getMinutes() == 0 ? '0' : '');

  $(timeClientId).append($('<option />').val(time).text(time));
} 

The above script creates a list of times available from 10:00am all the way to 02:00am the next day.

It runs fine until it reaches midnight 00:00 after many successful iterations.

Can anyone help?

Thanks!

ANSWER/SOLUTION:

This problem was due to a daylight saving issue, so this Saturday the clocks go forward. For some odd reason when adding 30 minutes to 12:30 it reset back to 12:00 using .setMinutes(). This kept it in an endless loop.
The solution was to add minutes using
i.setTime(i.getTime() + timeIncrement * 60 * 1000)
This sorted the issue.

Cheers for all your answers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:04:48+00:00Added an answer on May 31, 2026 at 6:04 pm

    You are only setting the minutes. So of course 30 minutes + 30 minutes on the clock equals 60 minutes, i.e. 0 minutes.

    Use this clever method (it’s clever because it works with all rollovers!):

    function addMinutes(inDate, inMinutes)
    {
        var newdate = new Date();
        newdate.setTime(inDate.getTime() + inMinutes * 60000);
        return newdate;
    }
    
    var date = new Date();
    
    alert(addMinutes(date,-30));​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have javascript date object which gives me a date string in this format,
I have an javascript object with Date property which is being converted to JSON
I'm trying to pass a javascript Date object to a controller that I have
I have a date object in JavaScript and I want to figure out if
I have a javascript function that checks for a date range. Is there any
i have a javascript method that takes a date: convert(new Date(02/20/2010); how can i
Is it possible in javascript to convert some date in timestamp ? i have
I have JavaScript that is doing activity periodically. When the user is not looking
I have javascript code embedded inside a html template file. When I load this
To compage 2 date i'm doing a conversion from a string to the javascript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.