JavaScript Date API Worksheet
Questions
This reference may be helpful in understanding how you can work with Date objects.
Question 1
If you invoke the Date constructor without passing in any parameters, what date will be stored in the object that is returned?
It would store the current date and time.
Question 2
What is an 'epoch'?
Epoch is the event when dates and time were first measured.
Question 3
What is a 'Unix timestamp' (also known as 'epoch time')?
Unix timestamp is the number of milliseconds that have elapsed since the Unix epoch. Unix epoch is when time and dates were first meausred in JavaScript.
Question 4
What is the actual date of the epoch for Unix timestamps?
January 1, 1970 at midnight.
Question 5
What does the getTime() method of a date object return (refer to the link that was mentioned above, or find another reference on the Date object in JavaScript)?
The getTime() method tells you how many milliseconds has passed since Unix epoch.
Question 6
If you are working with 2 date objects, how could you use the getTime() method to determine if one date is more recent than the other?
You would want to use the getTime() method on both dates then you could convert those millisecond to days to see which came first since itll be easier to read days then milliseconds.