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 4599782
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:35:25+00:00 2026-05-21T23:35:25+00:00

Hereby i am the following inputs: Months to be separated by : 4 months

  • 0

Hereby i am the following inputs:

Months to be separated by : 4 months

Will have the date with month and year: 07-05-2011.

Now i need to add months by 4 using JavaScript or jquery. How can this be done?

For example:

I am having the date as : 01-01-2011 and the duration is 4

My output should be:

01-12-2010

01-04-2011

01-08-2011

01-12-2011

For example if it is:

I am having the date as : 01-06-2011 and the duration is 4

My output should be:

01-06-2011

01-10-2011

01-02-2012

01-06-2012

Thanks in advance

  • 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-21T23:35:25+00:00Added an answer on May 21, 2026 at 11:35 pm

    Here you have:

    var initialDate = new Date(2011, 5, 1); //Your example number two. January is 0
    for(var i=0; i<4; i++){
      var newMonth = initialDate.getMonth() + i;
      var newYear = initialDate.getYear();
      if(newMonth >= 12){
         newMonth = newMonth % 12;
         newYear ++;
      }
      var newDate = new Date(newYear, newMonth, 1);
      alert(newDate);
    }
    

    Hope this helps. Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following types of strings: 17082011T1015 In other words: day month year
I'm building a video player using Flash CS4 (hereby referred to as Flash) to
I have the following test code: <?php $letter = 'A'; $letter++; $letter++; echo $letter.'<br>';
Right now, I have everything fine. It prints according to my CSS (text-align: center;).
I have the following code in a controller: <?php class Student extends CI_Controller {
i was dealing with the following code,& got confused,please have a look at it
I have indexed my database using Hibernate Search. I use a custom analyzer, both
Now i have a requirement in jquery. But my jsp page not loading the
I have the following code and i am programming in c++ :- I followed
like in this post here by exemple I have found this blog but in

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.