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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:45:58+00:00 2026-06-05T05:45:58+00:00

I want to let users easily add and subtract dates using JavaScript in order

  • 0

I want to let users easily add and subtract dates using JavaScript in order to browse their entries by date.

The dates are in the format: “mm/dd/yyyy”. I want them to be able to click a “Next” button, and if the date is: ” 06/01/2012″ then on clicking next, it should become: “06/02/2012”. If they click the ‘prev’ button then it should become, “05/31/2012”.

It needs to keep track of leap years, number of days in the month, etc.

Any ideas?

P.S using AJAX to get the date from the server isn’t an option, its a bit laggy and not the experience for the user that the client wants.

  • 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-06-05T05:46:00+00:00Added an answer on June 5, 2026 at 5:46 am

    Code:

    var date = new Date('2011', '01', '02');
    alert('the original date is ' + date);
    var newdate = new Date(date);
    
    newdate.setDate(newdate.getDate() - 7); // minus the date
    
    var nd = new Date(newdate);
    alert('the new date is ' + nd);

    Using Datepicker:

    $("#in").datepicker({
        minDate: 0,
        onSelect: function(dateText, inst) {
           var actualDate = new Date(dateText);
           var newDate = new Date(actualDate.getFullYear(), actualDate.getMonth(), actualDate.getDate()+1);
            $('#out').datepicker('option', 'minDate', newDate );
        }
    });
    
    $("#out").datepicker();​
    

    JSFiddle Demo

    Extra stuff that might come handy:

    getDate()   Returns the day of the month (from 1-31)
    getDay()    Returns the day of the week (from 0-6)
    getFullYear()   Returns the year (four digits)
    getHours()  Returns the hour (from 0-23)
    getMilliseconds()   Returns the milliseconds (from 0-999)
    getMinutes()    Returns the minutes (from 0-59)
    getMonth()  Returns the month (from 0-11)
    getSeconds()    Returns the seconds (from 0-59)
    

    Good link: MDN Date

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

Sidebar

Related Questions

I want to let users login to my website using their Facebook, or Twitter
We want to let users click a thumbs up or thumbs down button from
I want to let users upload Images. The file gets re-named (by adding the
I want to build a flash app to let me and my users snap
I want to implement functionality which let user share posts by other users similar
This is what I want : Let the user enter as many numbers as
So I have a file for constants. I want to let user define them
I want to let the user download the current content of a textarea into
Selenium provide many kinds of browser driver, so I want to let the user
I want to use jquery draggable/droppable to let the user select a group of

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.