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

  • Home
  • SEARCH
  • 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 8176251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:05:35+00:00 2026-06-06T23:05:35+00:00

Javascript definitely isn’t my strongest point. I’ve been attempting this for a couple of

  • 0

Javascript definitely isn’t my strongest point. I’ve been attempting this for a couple of hours now and seem to be getting stuck with date formatting somewhere.

I have a form where a user selected a date (dd/mm/yyyy) and then this date will be taken and 2 weeks will be added to it and then date will be copied to another form field.

My latest attempt below isn’t even adding a date yet just copying the selected date in one form field to another, if I select ’03/02/2012′, it outputs ‘Fri Mar 02 2012 00:00:00 GMT+0000 (GMT Standard Time)’, so its outputting in American format as well as the full date. How to I get it to out put in the same format and add 2 weeks?

function LicenceToOccupy(acceptCompletionDate)
{
    var date1 = new Date(acceptCompletionDate);
    document.frmAccept.acceptLicence.value = date1;

}
  • 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-06T23:05:38+00:00Added an answer on June 6, 2026 at 11:05 pm

    You can do this :

    const numWeeks = 2;
    const now = new Date();
    now.setDate(now.getDate() + numWeeks * 7);
    

    or as a function

    const addWeeksToDate = (dateObj,numberOfWeeks) => {
      dateObj.setDate(dateObj.getDate()+ numberOfWeeks * 7);
      return dateObj;
    }
    
    const numberOfWeeks = 2 
    console.log(addWeeksToDate(new Date(), 2).toISOString());
    

    You can see the fiddle here.

    According to the documentation in MDN

    The setDate() method sets the day of the Date object relative to the beginning of the currently set month.

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

Sidebar

Related Questions

Why isn't this passing text to javascript/jquery.? @i[:error] definitely has a string in it,
I'm at my wit's end when it comes to this. JavaScript definitely isn't my
First up, JavaScript is definitely not my native tongue. Nevertheless, I've been tasked with
According to this tutorial , the DatePicker control is definitely present in the Javascript
I'm definitely still learning Javascript so please forgive me if this is a very
JavaScript/JQuery var arr=[]; $('.element').each(function(i) { arr.push({id:i,value:$(this).attr('data-value')}); }); $.get('/json.php?arr='+arr,function(result) { alert(result); }); PHP <?php $j
Javascript is pretty shaky for me, and I can't seem to find the answer
I haven't been able to find a good answer to this issue. I'm trying
I've been doing some reading about two (relatively) new concepts in the Javascript language
Ok I am definitely puzzled, why this is not returning 6 in textarea. It

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.