View Full Version : setDate(???) expected parameters

04-08-2003, 06:00 PM
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();

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)

04-08-2003, 06:15 PM
It takes an integer value from 1-31


04-08-2003, 07:56 PM
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);

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 ?

04-08-2003, 08:08 PM
to add 10 days to d

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

04-09-2003, 03:09 AM
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 ?)

04-09-2003, 06:10 AM
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


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum