Timestamps, dates, and time zones
Distinguish seconds, milliseconds, UTC, and local display.
- Difficulty
- beginner
- Time
- 45 minutes
- Last verified
- 9/21/2026
What you will build
Distinguish seconds, milliseconds, UTC, and local display.
Understand the idea first
Distinguish seconds, milliseconds, UTC, and local display.
Build it step by step
const seconds = 1760000000;
const date = new Date(seconds * 1000);
const local = new Intl.DateTimeFormat(undefined, {
dateStyle: 'medium',
timeStyle: 'short',
}).format(date);
console.log(date.toISOString(), local);- Open the previous project and record its result.
- Type the example and complete: Format one instant as ISO, local time, and Asia/Shanghai; explain the difference.
- Change one input, predict, then verify.
- Create and repair: Unix seconds need ×1000; do not store a formatted display string.
Read the important lines
- Distinguish seconds, milliseconds, UTC, and local display.
- Read input, processing, and output separately.
- Verify another input and an edge case.
Common mistakes and what to check
| Symptom | What to check |
|---|---|
| Unexpected result | Unix seconds need ×1000; do not store a formatted display string. |
| Nothing changes | Save, verify paths, and read the first relevant Console error. |
Practice without copying
Format one instant as ISO, local time, and Asia/Shanghai; explain the difference.
Check the answer after you try
Rebuild and explain the decisions. Check: Unix seconds need ×1000; do not store a formatted display string.
Completion check
- I produced the required visible result
- I can explain the input, processing, and output
- I tested normal, edge, and failure cases