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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:37:42+00:00 2026-05-23T23:37:42+00:00

I called new Date(Jan 4) and found the default year is 2001 a=new Date(Jan

  • 0

I called new Date(“Jan 4”)
and found the default year is 2001

a=new Date("Jan 4")
Thu Jan 04 2001 00:00:00 GMT-0500 (EST)

Is there any way that I can set the default year to be 2011?


update:
I know that I can use + 2011
but since I have some “Jan 4”, and some “Jan 4, 2008”
I only want to use 2011 for the former case.

However, I realize that if you do Date(“Jan 4, 2008 2011”) the year will be 2008 but not 2011. That’s just what I need.
I will mark the first answer correct anyway.

  • 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-23T23:37:42+00:00Added an answer on May 23, 2026 at 11:37 pm

    Can you try :

    year = new Date().getFullYear(); // current year
    a=new Date("Jan 4"+' '+year);
    

    Update

    You can split the string using

    'Jan 4, 2008'.split(',')[0]+' '+year;
    'Jan 4'.split(',')[0]+' '+year; // still works
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a new Stage called field to the default one (i
Let's say I have a datePicker called foobar: <g:datePicker name=foobar value=${new Date()} precision=day />
i have a date/time field called MyDate. Originally, its format is mm/dd/yyyy and there
I'm designing a new protocol called DITP. It is a connection oriented protocol that
The new Android 2.1 SDK (version 7) has a new class called SignalStrength: http://developer.android.com/reference/android/telephony/SignalStrength.html
C# 4.0 introduced a new type called 'dynamic'. It all sounds good, but what
In Powershell I am defining a new PSDrive called test . But when I
I am trying to create a new db called testDB2, below is my code.
I noticed a new web service today called a Dead man's switch , which
I'm building what could be called the DAL for a new app. Unfortunately, network

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.