Chapter 6. Date Object
Q. What are the different ways to create a Date object? Or what are the different constructor forms of Date object?
new Date(year, month, day, hours, minutes, seconds, milliseconds)
Q. How to get 1st January 1970 in a date object, the date from where time is gets calculated?
1st January 1970 is the day from where the time is get calculated as number of milliseconds elapsed. It can be calculated by creating a new JS object with parameter 0.below screenshot demonstrate the date object with parameter 0.
Q. When RangeError invalid date exception occurs?
When a date object is created with invalid date string and toISOString() method is applied to this invalid date then this RangeError occurs. Below screenshot shows '2014-13-13' string which is representing YYYY-MM-DD format where month is out of range produces the RangeError exception.