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

SymbolMeaningExampleNote
YYYY4-digit year2026Full year
YY2-digit year26Last two digits of year
MM2-digit month0601-12
MMonth61-12
DD2-digit day1401-31
DDay141-31
HH24h hour1000-23
hh12h hour1001-12
mmMinutes3000-59
ssSeconds0000-59
SSSMilliseconds123000-999
AAM/PMAMUppercase
aam/pmamLowercase
ZTimezone offset+08:00ISO 8601
XUnix timestamp (s)1718347800Integer
xUnix timestamp (ms)1718347800000Integer

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