dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Adding days to a certain Date

  1. #1
    Join Date
    Sep 2008
    Posts
    10

    Adding days to a certain Date

    Hi, I wanted to add 30days to a given Date (not today's date). ex: I wanted to add 30days to October 12,2008. Can Anyone please show me how to write this function.

    I just don't know how to create the date object for the date October 12, 2008.
    Please help!!!

    Thanks in advance

  2. #2
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    Code:
    var date = new Date(2008, 9, 12); // in javascript, 9 is october
    date.setDate(date.getDate() + 30);
    alert(date.toString());
    create the date object, then set a new date by adding 30 days to the date's object.

  3. #3
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by Ann03 View Post
    I just don't know how to create the date object for the date October 12, 2008.
    http://www.w3schools.com/js/js_obj_date.asp

  4. #4
    Join Date
    Sep 2008
    Posts
    10
    Thanks ZeroKilled . that works !!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles