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

Chapter 13. Dealing with Dates and Times... > Working with the Date Object

Working with the Date Object

Whenever you work with dates and times in JavaScript, you work with an instance of the Date object. More to the point, when you deal with a Date object in JavaScript, you deal with a specific moment in time, down to the millisecond. A Date object can never be a block of time, and it's not a kind of clock that ticks along while your script runs. Instead, the Date object is a temporal snapshot that you use to ex+tract the specifics of the time it was taken: the year, month, date, hour, and so on.

Specifying the Current Date and Time

The most common use of the Date object is to store the current date and time. You do that by invoking the Date() function, which is the constructor function for creating a new Date object. Here's the general format:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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