Date Object in javascript
The Date object represents points in time. You can create dates for now or a specific timestamp, and then read or set components like year, month, day, hours. Methods like toISOString and toLocaleString format dates for storage or display.
Example
const now = new Date();
now.toISOString(); // '2026-03-04T...Z'
const birthday = new Date(1998, 4, 15); // May 15, 1998 (month is 0‑based)
const year = birthday.getFullYear(); // 1998
// Difference in days
const diffMs = now.getTime() - birthday.getTime();
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));Dates are internally stored as milliseconds since the Unix epoch; getTime plus simple arithmetic lets you compute durations like age or time differences.