Tuesday, September 24, 2013

Get first day of previous month on JavaScript

Hi All,

Please find below javascript code to get the first day of the previous month

var ourDate = new Date();
//roll it back to the last day of last month
ourDate.setDate(-1);
//now that we’re in the proper month, let’s go back to the first day…
ourDate.setDate(0);
// and now we have it
alert(ourDate);


Thanks,

Sachin K.

No comments:

Post a Comment