Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: What is Date class in Javascript? Please explain.
Answer: to create a Date object, use new & supply year/month/day/… as desired

today = new Date(); // sets to current date & time

newYear = new Date(2002,0,1); //sets to Jan 1, 2002 12:00AM

methods include:

newYear.getYear() can access individual components of a date
newYear.getMonth()
newYear.getDay()
newYear.getHours()
newYear.getMinutes()
newYear.getSeconds()
newYear.getMilliseconds()
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook