Date object (which also stores time data) is not one of the language’s best-designed features. Because of the limited utility of this built-in object, I will be introducing Moment.js, which extends the functionality of the
Date object to cover commonly needed functionality.
Date object was originally implemented by Netscape programmer Ken Smith—who essentially ported Java’s
Date object and a common syntactic ancestor, very little.”
Because it gets tedious to keep repeating “date and time,” I will use “date” to implicitly mean “date and time.” A date without a time is implicitly 12:00 A.M. on that day.
Let’s face it: our modern Gregorian calendar is a fussy, overcomplicated thing, with 1-based numbering, odd divisions of time, and leap years. Time zones add even more complexity. However, it’s (mostly) universal, and we have to live with it.
We’ll start with something simple: the second. Unlike the complicated division of time in the Gregorian calendar, seconds are easy. Dates and times—as represented by seconds—are a single number, neatly ordered ...