• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 13. Dealing with Dates and Times... > Performing Date Calculations

Performing Date Calculations

Many of your date-related scripts will need to make arithmetic calculations. For example, you might need to figure out the number of days between two dates, or you might need to calculate the date that is 6 weeks from today. The methods you've seen so far and the way JavaScript represents dates internally serve to make most date calculations straightforward,

The simplest calculations are those that involve whole numbers of the basic JavaScript date and time units: years, months, days, hours, minutes, and seconds. For example, suppose you need to calculate a date that's five years from the current date. Here's a code snippet that will do it:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint