Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Location
    Chicago, Illinois, U.S.A.
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Return the month of the previous Sunday.

    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.

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    726
    Thanks
    35
    Thanked 132 Times in 123 Posts
    Code:
    Date.monthnames= ['January', 'February', 'March', 'April', 'May', 'June',
    'July', 'August', 'September', 'October', 'November', 'December'];
    Code:
    Date.lastSundayMonth= function(d){
    	var now= d || new Date;
    	now.setDate(now.getDate()-now.getDay());
    	return Date.monthnames[now.getMonth()];
    }

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

  • Users who have thanked mrhoo for this post:

    LostShadow (07-01-2009)

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Location
    Chicago, Illinois, U.S.A.
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Edit: nevermind... I got it fixed.
    Last edited by LostShadow; 07-01-2009 at 02:21 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •