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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:59:31+00:00 2026-06-15T19:59:31+00:00

Hi I am trying to create a variable today that is the current date

  • 0

Hi I am trying to create a variable today that is the current date today. I am trying to add 106 days to it which works successfully. Then I am trying to create a second variable today2 and subtract 31 days from the ‘today’ variable (current date + 106 -31). This part is not working. This is what it is giving me…

Thu Mar 28 11:52:21 EDT 2013
Tue Nov 27 11:52:21 EST 2012

The second line is not 31 days before the first line. Can someone help me correct this?

Feel free to play with my jsfiddle http://jsfiddle.net/fjhxW/

<div id="current"></div>
<div id="current2"></div>
<div id="current3"></div>

var today = new Date();
var today2 = new Date();

today.setDate(today.getDate() + 106);

today2.setDate(today.getDate() - 31);  

var dd = today.getDate();
var mm = today.getMonth(); //January is 0!
var yy = today.getFullYear();

document.getElementById('current').innerHTML = today;
document.getElementById('current2').innerHTML = today2;
  • 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-15T19:59:32+00:00Added an answer on June 15, 2026 at 7:59 pm

    it’s Xmas time so I give the answer just to copy/paste:

    var oneDay = 24 * 60 * 60 * 1000, // 24h
        today = new Date().getTime(), // in ms
        firstDate,
        secondDate;
    
    firstDate = new Date(today + 106 * oneDay);
    secondDate = new Date(firstDate.getTime() - 31 * oneDay);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a variable that gets the current date and time
I've been trying to create a new variable of type Cmplx (which is my
I'm trying to create a new variable that will consist of an existing dictionary
I am trying to create a variable that will enable me to echo out
I am trying to create a variable that will include another variable. Example: var
I am trying to create a variable that is equal to nothing. I have
I am trying to create a variable that performs a couple of different replacement
I am trying to create a variable of type MulticastLock , which is an
Running into a spot of trouble and basically trying to create a variable which
I have a data frame. I'm trying to create a dummy variable that is

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.