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?

The date object that is returned will have the current date based on the computer.

Question 2

What is an 'epoch'?

It is a reference point to measure time. it is 00:00:00 on January 1st 1970

Question 3

What is a 'Unix timestamp' (also known as 'epoch time')?

It is the number of miliseconds that have gone by since epoch.

Question 4

What is the actual date of the epoch for Unix timestamps?

It is 00:00:00 on January 1st 1970.

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)?

It returns the number of miliseconds that have gone by since 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?

If you have 2 varibles we could use the getTime() method to determine wich date is more recent by using an if else statement.