Chapter 18. The Date, Time, and String Objects

The Date, Time, and String Objects

In this chapter, we’ll take a look at two important JavaScript objects: the Date and String objects. Both are fairly extensive, and both are useful. As you can guess from their names, the Date object enables you to work with dates, and the String object enables you to work with strings. I’ll discuss the Date object in detail first.

The Date Object

Date objects store dates and provide many methods to extract the hours, minutes, and so on parts of dates. There are a number of different ways to create Date objects, such as the following:

 var date1 = new Date() var date1 = new Date(dateVal) var date1 = new ...

Get Inside JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.