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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:56:22+00:00 2026-06-05T18:56:22+00:00

I know a way to do in java: Calendar c5 = Calendar.getInstance(); c5.add(Calendar.MONTH, -6);

  • 0

I know a way to do in java:

Calendar c5 = Calendar.getInstance();
c5.add(Calendar.MONTH, -6);
c5.getTime(); //It will give YYYYMMDD format three months ago.

Is there a way to do this in javascript. I know that I can use
Date d = new Date(); parse it and do some code to get the format.
But now I dont want to do parsing and getting three month ago date.

  • 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-05T18:56:24+00:00Added an answer on June 5, 2026 at 6:56 pm
    var dt = new Date('13 June 2013');
    dt.setMonth(dt.getMonth()-1)
    

    Then you can use this piece of code from this answer to convert it to YYYYMMDD

     Date.prototype.yyyymmdd = function() {
       var yyyy = this.getFullYear().toString();
       var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
       var dd  = this.getDate().toString();
       return yyyy + (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]); // padding
      };
    
    d = new Date();
    d.yyyymmdd();
    

    Something to be careful of. If you’re at Mar 31 and subtract a month, what happens? You can’t get Feb 31! See this answer for more details.

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

Sidebar

Related Questions

Possible Duplicate: Anyone know a simple way using java calendar to subtract X days
Possible Duplicate: Anyone know a simple way using java calendar to subtract X days
Does anyone know of a neat way in java or any packages that will
Anyone know a simple way using Java calendar to subtract X days from a
is there any other way to know if the java String contains character-encoding in
Coming from the basic Java world I know there's a way to spawn a
Is there a good way to detect deletes in Java? I know I can
Is there an easy way to manipulate PNGs in Java? I know I can
As you know, the proper way to create a Dom Element in Java is
I wish to know the way to add ASP.NET (Machine_Name\IIS_IUSRS) to user role in

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.