Announcement

Collapse
No announcement yet.

Date math

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date math

    I have a Date object:

    var today = new Date();

    I want to add 7 days to it. Can this be done in javascript?

    I've tried the following which don't work:

    var nextDate = today + 7;
    var nextDate = today + new Date(1970, 0, 7)

    Thanks
    Standing on the shoulders of giants.

  • #2
    Re: Date math

    var myDate=new Date()
    myDate.setDate(myDate.getDate()+7)
    ---------------------------------------------------------

    Originally posted by wildfiction
    I have a Date object:

    var today = new Date();

    I want to add 7 days to it. Can this be done in javascript?

    I've tried the following which don't work:

    var nextDate = today + 7;
    var nextDate = today + new Date(1970, 0, 7)

    Thanks

    Comment


    • #3
      Thanks AssetHound - that did the trick.
      Standing on the shoulders of giants.

      Comment

      Working...
      X