views:

205

answers:

2

I was trying to execute the below code in my javascript and got some exception

 var now3 = new Date();
 now3.addDays(-4);

Error throwed is Microsoft JScript runtime error: Object doesn't support this property or method

I m using jQuery 1.3.2 in my page .

Whats wrong with this? Please help

+5  A: 

There is no addDays() method - you need to use setDate():

now3.setDate(now3.getDate() - 4);

See the Date object documentation for more information.

Greg
A: 

Greg's hint is the wat to go. You can find more info on javascript date manipulations @ http://www.w3schools.com/js/js_obj_date.asp

Dominik Ras