...

View Full Version : Return the month of the previous Sunday.



LostShadow
06-29-2009, 07:03 PM
This is what I got:

var m = new Month; m.setMonth(m.getMonth() - (m.getDay()));
var monthnow = new Date(); monthnow.setMonth(0); monthnow.getMonth()
document.write("Week of "+ m.getMonth());
document.write(", 2009.");

Trying to return the month of the month of last Sunday. So if today is Sunday, will return today's month.

:/

Thanks.

mrhoo
06-30-2009, 04:40 AM
Date.monthnames= ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'];


Date.lastSundayMonth= function(d){
var now= d || new Date;
now.setDate(now.getDate()-now.getDay());
return Date.monthnames[now.getMonth()];
}


//test
alert(Date.lastSundayMonth());

LostShadow
06-30-2009, 05:57 PM
Edit: nevermind... I got it fixed.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum