Date The object helps you work with dates and times. date new Date() date You can create a object set to a specific date or time, in which case you need to pass it one of four parameters: : This value should be the number of milliseconds since 01/01/1970. milliseconds : Can be any date in a format recognized by the method. dateString parse() , , : Represents year, and day. yr_num mo_num day_num , , , , , , : Represents the years, days, hours, minutes, yr_num mo_num day_num hr_num min_num seconds_num ms_num seconds, and milliseconds. examples; milliseconds will read : Thu Nov 27 05:33:20 UTC 1975 var birthDate = new Date(8298400000) document.write(birthDate) will read : dateString Wed Apr 16 00:00:00 UTC+0100 1975 var birthDate = new Date(“April 16, 1975”) , , and , and will read : yr_num mo_num day_num Mon May 12 00:00:00 UTC+0100 1975 var birthDate = new Date(1975, 4, 28) document.write(birthDate) The first confusing thing you might notice here is that the number 4 corresponds to the month of May! That makes January 0. Similarly, when working with days, Sunday is treated as 0. You might find that you get different time zones than I do. I am based in London, so I run on Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC). All the date object workings are performed using UTC, ’s even though your computer may display a time that is consistent with your time zone. While you can add or subtract dates, your result will end up in milliseconds. example, if I wanted to find out the number of days until the end of the year, I might use something like this var today = new Date()
Date The date object helps you work with dates and times. new Date() You can create a date object set to a specific date or time, in which case you need to pass it one of four parameters: milliseconds : This value should be the number of milliseconds since 01/01/1970. dateString : Can be any date in a format recognized by the parse() method. yr_num , mo_num , day_num : Represents year, and day. yr_num , mo_num , day_num , hr_num , min_num , seconds_num , ms_num : Represents the years, days, hours, minutes, seconds, and milliseconds. examples; milliseconds will read Thu Nov 27 05:33:20 UTC 1975 : var birthDate = new Date(8298400000) document.write(birthDate) dateString will read Wed Apr 16 00:00:00 UTC+0100 1975 : var birthDate = new Date(“April 16, 1975”) yr_num , mo_num , and day_num , and will read Mon May 12 00:00:00 UTC+0100 1975 : var birthDate = new Date(1975, 4, 28) document.write(birthDate) The first confusing thing you might notice here is that the number 4 corresponds to the month of May! That makes January 0. Similarly, when working with days, Sunday is treated as 0. You might find that you get different time zones than I do. I am based in London, so I run on Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC). All the date object ’s workings are performed using UTC, even though your computer may display a time that is consistent with your time zone. While you can add or subtract dates, your result will end up in milliseconds. example, if I wanted to find out the number of days until the end of the year, I might use something like this var today = new Date()