A JavaScript date can be written as a string:

Tue Jun 27 2017 14:24:16 GMT+0900 (KST)

or as a number:

1498541056831

Dates written as numbers, specifies the number of milliseconds since January 1, 1970, 00:00:00.

There are 4 ways of initiating a date:

new Date()                // current date and time
new Date(milliseconds)    // zero time plus the number
new Date(dateString)      // specified date and time
new Date(year, month, day, hours, minutes, seconds, milliseconds) // specified date and time

JavaScript counts months from 0 to 11. January is 0. December is 11.

var d = new Date(99, 5, 24, 11, 33, 30, 0);
var d = new Date(99, 5, 24);  // the last 4 parameters can be omitted

When setting a date, without specifying the time zone, JavaScript will use the browser’s time zone.

When getting a date, without specifying the time zone, the result is converted to the browser’s time zone.


Yonggoo Noh

I am interested in Computer science and Mathematics.