I want to get the before six months date using javascript.
I am using the following method.
var curr = date.getTime(); // i will get current date in milli seconds
var prev_six_months_date = curr - (6* 30 * 24 * 60* 60*1000);
var d = new Date();
d.setTime(prev_six_months_date);
Is this the right way or any better way to get the last six months date.
If this get fixed I want to apply this logic to get previous dates like last 2 months and last 10 years etc.
If any body give the solution in jquery also very helpful to me. Thanks in advance.
date.getTime()with$.now().var d = new Date();d.setMonth(d.getMonth()-6)Similarly, you can usesetYears()andsetDate()