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.
Then you can use this piece of code from this answer to convert it to 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.