If i have a variable that returns a date, in the format of dd MMM yyyy, so 28 Aug 2014, how can i get the date of the previous month.
I can modify the month via:
Just subtract the number of months from the month parameter and don't worry if the value is going to be negative. It will be handled correctly.
new Date(2014, 0, 1) // 1st Jan 2014 new Date(2014, -1, 1) // 1st Dec 2013