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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:14:11+00:00 2026-05-23T19:14:11+00:00

Doing some code in JavaScript/jQuery and I need to have it where the user

  • 0

Doing some code in JavaScript/jQuery and I need to have it where the user can enter a somewhat partial date string and have JavaScript figure out the full date.

For example, if the user enters “5/24” it should return “5/24/2011” (the current year). If the user enters “5/24/2004” it should return just that.

duedate = Date.parse(qadueparse);
duedatelit = new Date(duedate);
duedatelit = Number(duedatelit.getMonth()+1) + '/' + 
    Number(duedatelit.getDate()) + '/' + Number(duedatelit.getFullYear());

This above code works when the user supplies a full string, however it seems to screw up on me when the user types “5/24” or some other partial string. It returns a year of 2001.

Can anyone help me out?

Turning once again to StackOverflow for my programming needs; thank you, everyone, in this vibrant community for supporting each other.

  • 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-23T19:14:12+00:00Added an answer on May 23, 2026 at 7:14 pm

    The date object can accept a deconstructed date for instantiation:

    var d = new Date(2011, 7, 13, 15, 59, 0); // Jul 13th, 3:59:00pm
    

    You can rip apart the partial date and fill in the blanks yourself. However, what is 3/7? March 7th? July 3rd? Worse yet, 3/5/7 – which is year, which is month, which is day?


    comment followup:

    If it’s always m/d, then you just split on the /, giving you m and d values.

    provided = '5/24';
    parts = provided.split('/');
    
    month = parts[0]; // 5
    day = parts[1]; // 24
    
    today = new Date();
    
    your_date = new Date(today.getFullYear(), month, day); // new date object for 2011/5/24
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some javascript/jquery code and need to some php into it be the
I have some jquery code that is doing an ajax lookup and returning comma
I have some code doing this : var changes = document.getElementsByName(from); for (var c=0;
I have some cross platform DNS client code that I use for doing end
I'm writing a custom widget that requires some supporting javascript code that I need
I've got this page I'm doing some tests in Javascript and jQuery: JS Tests
I'm doing some ASM code in a C code with the asm function. My
I'm doing some dynamic code generation using Reflection, and I've come across a situation
I'm doing some unit testing, and some of the code is checking to see
some code snippets. The java coding doing the jaxb unmarshaling. pretty straightforward, copied out

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.