Chapter 18. 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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.