Date Format Reference
Date Format Quick Reference by Language
ISO 86011970-01-01T00:00:00.000Z
Chinese Date1970年0101日
YYYY-MM-DD1970-01-01
YYYY-MM-DD HH:mm:ss1970-01-01 08:00:00
Unix 秒0
Unix 毫秒0
Format Symbols Quick Reference
| Symbol | Meaning | Example | Note |
|---|---|---|---|
| YYYY | 4-digit year | 2026 | Full year |
| YY | 2-digit year | 26 | Last two digits of year |
| MM | 2-digit month | 06 | 01-12 |
| M | Month | 6 | 1-12 |
| DD | 2-digit day | 14 | 01-31 |
| D | Day | 14 | 1-31 |
| HH | 24h hour | 10 | 00-23 |
| hh | 12h hour | 10 | 01-12 |
| mm | Minutes | 30 | 00-59 |
| ss | Seconds | 00 | 00-59 |
| SSS | Milliseconds | 123 | 000-999 |
| A | AM/PM | AM | Uppercase |
| a | am/pm | am | Lowercase |
| Z | Timezone offset | +08:00 | ISO 8601 |
| X | Unix timestamp (s) | 1718347800 | Integer |
| x | Unix timestamp (ms) | 1718347800000 | Integer |
Date Format Code by Language
JavaScript
// 原生 Date
const now = new Date();
now.toISOString() // 2026-06-14T02:30:00.000Z
now.toLocaleDateString('zh-CN') // 2026/6/14
now.toLocaleString('zh-CN', {
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit'
})
// Intl.DateTimeFormat
new Intl.DateTimeFormat('zh-CN', {
dateStyle: 'full', timeStyle: 'long'
}).format(now)
// 推荐库: dayjs / date-fns / luxon
import dayjs from 'dayjs'
dayjs().format('YYYY-MM-DD HH:mm:ss')
dayjs().format('YYYY年MMDD日 dddd')Date Format Guide
Common Standard Formats
- ISO 8601: 2026-06-14T10:30:00Z
- RFC 2822: Sun, 14 Jun 2026 10:30:00 +0800
- Unix Timestamp: seconds/milliseconds
- Built-in format functions by language
Notes
- Month: JS starts at 0, others mostly start at 1
- Timezone handling: UTC vs local time
- 12h/24h format distinction (AM/PM)
- Be aware of internationalization (i18n) differences