12.1. An introduction to date and time functions
12.1.1. Working with the date object
In Chapter 7, you learned how to use the time functions getTime() and setTime() to set and change the expiry date of a cookie. These two functions are designed to manipulate the time stores in a date object. The following is typical example code used to get the date and time of yesterday.
1: dateObj = new Date() 2: currentTime = dateObj.getTime() 3: yesterdayDate = currentDate – 1000*60*60*24
The first line is used to create a new object variable (or instance) named dateObj from the date object provided by the browser. Once we have done that, we can access all the methods of the object from the dateObj variable as demonstrated in line 2 (i.e., the getTime() ...
Get Practical Web Technologies 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.