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 6 of 6
  1. #1
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts

    setDate(???) expected parameters

    Hi trying to setDate() but have not a clue of the expected parameters ...

    I saw somewhere (where yyyy,dd,mm are integers)

    d = new Date();
    d.setDate(yyyy,mm,dd);
    alert(d.toDateString());

    but that always gives an incorrect answer , other variations give NaN .. anyone know what the correct format is ? - or a decent date object reference (I only have MS Jscript reference which is useless)
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    It takes an integer value from 1-31

    http://devedge.netscape.com/library/...e.html#1194228
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    doh , cheers Spookster , why I am looking at MS jscript docs I dont know~

    errr still up the spout though , I am trying to add 10 days to a given date from form input...

    d= new Date(parseInt(year), parseInt(month), parseInt(day));
    var md=d.valueOf() + 86400000 *10;//milliseconds ..should be 10 days ?//
    var newdate=new Date(md);
    alert(newdate);


    it does incrememnt the date by 10 days (mostly)... but also adds one to the month and does weird things at the end of the month ? anyone got a better way for me ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    New York, USA
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    to add 10 days to d

    d.setDate(d.getDate() + 10);

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    cheers - that works a treat ... still have to -1 from the getMonth() value ? but I can live with that (and its probably something I broke elsewhere anyway ?)
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    By default the Date object returns a zero-based value.

    Hey firepages, being the PHP person you are, you might appreciate my Date class for JS

    http://www.peterbailey.net/dhtml/dates.htm
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

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