How do you create a new Date object for the current date and time?
A
new Date() B
Date.now() C
createDate() D
new DateTime()
Analysis & Theory
`new Date()` creates a new Date object with the current date and time.
What does `Date.now()` return?
A
Current date as a string B
Milliseconds since Jan 1, 1970 C
A Date object D
Seconds since Jan 1, 2000
Analysis & Theory
`Date.now()` returns the number of **milliseconds since January 1, 1970 (Unix epoch).`
Which method returns the year from a Date object?
A
getFullYear() B
getYear() C
getDate() D
getMonth()
Analysis & Theory
`getFullYear()` returns the full 4-digit year (e.g., 2025).
Which method gets the day of the month (1–31)?
A
getDay() B
getDate() C
getMonth() D
getHours()
Analysis & Theory
`getDate()` returns the day of the month (1–31).
What does `getDay()` return?
A
The current day of the month B
The weekday number (0–6) C
The number of days in the month D
The day in text (e.g., 'Monday')
Analysis & Theory
`getDay()` returns the **weekday number**, where 0 = Sunday, 1 = Monday, etc.
How do you get the current month number (0–11)?
A
getMonth() B
getDate() C
getFullMonth() D
getCurrentMonth()
Analysis & Theory
`getMonth()` returns the month as a number between 0 (January) and 11 (December).
How can you set the year in a Date object?
A
setYear() B
setFullYear() C
changeYear() D
updateYear()
Analysis & Theory
`setFullYear(year)` sets the year for a Date object.
Which method returns the date as a string?
A
toDateString() B
getDateString() C
asString() D
dateFormat()
Analysis & Theory
`toDateString()` returns a readable string representation of the date (e.g., 'Tue Jul 01 2025').
What is the output of `new Date('2025-12-25').getMonth()`?
A
12 B
11 C
10 D
0
Analysis & Theory
Months are 0-based, so December is `11`.
Which method returns the time in milliseconds since the Unix Epoch?
A
getTime() B
getHours() C
getMilliseconds() D
timeNow()
Analysis & Theory
`getTime()` returns the number of milliseconds since Jan 1, 1970.