Reputation: 3998
I have following code
startDate = "2012-08-12"
I am subtracting 30 days from that date
var date = new Date(startDate);
var newDate = date.setDate(date.getDate() - 30);
I want to convert that newDate in the format yyyy MMM dd
2012 JUL 11
(subtracting 30 days from the date)
EDIT
I don't want to use any plugins
I have been trying a long method to extract date, month and year and an array of months then substituting it.
Upvotes: 2
Views: 1299
Reputation: 2681
You could do this as following:
myDate= Date.parse("2012-08-12") - 2592000000;
newDate = new Date(myDate);
Just parse the date so you get a number
Upvotes: 3