Date
EasyIn plain terms
Date represents a point in time. Create with new Date(). Get/set methods for year, month, day, hours, etc. Months are 0-indexed. Use for timestamps and formatting dates.
What you need to know
- •new Date()
- •Months 0-11
- •Milliseconds since epoch
Try it yourself
Copy the code below and run it in your browser console or a code editor:
const now = new Date();
const specific = new Date(2025, 0, 15); // Jan 15, 2025
const fromStamp = new Date(1609459200000);
now.getFullYear(); // 2025
now.getMonth(); // 0-11!
now.getDate();
now.getHours();
now.toISOString(); // "2025-02-12T..."
now.getTime(); // milliseconds since epochLearn more
Dive deeper with these trusted resources: