Date & Time Formats Reference
Date and time formats reference: standard formats like Unix timestamp, ISO 8601, RFC 3339, RFC 2822 and common display patterns with meaning and examples.
How It Works
Time representation has two layers: the "absolute instant" — a unique point on the timeline (e.g. Unix timestamp 1693564800) independent of display — and the "display format", a human-readable writing affected by locale, calendar and timezone. The same instant renders differently across regions, so store the absolute instant plus timezone and format for display per user locale.
Formats originate differently: the Unix timestamp counts seconds/ms since 1970-01-01 UTC and is best for computation; ISO 8601 / RFC 3339 are human-readable yet machine-unambiguous standards ideal for APIs and logs; RFC 2822 is common in email and HTTP headers. When mixing them, always confirm the unit (seconds vs ms) and timezone, or you get a 1000x error or a wrong-zone offset.
| Format | Meaning | Example |
|---|---|---|
| Unix 时间戳 | Seconds (or ms) since 1970-01-01 UTC | 1693564800 |
| ISO 8601 | ISO date-time format | 2023-09-01T12:00:00Z |
| ISO 8601(含时区偏移) | Local time with +08:00 style offset | 2023-09-01T20:00:00+08:00 |
| RFC 3339 | Strict subset of ISO 8601, common in APIs | 2023-09-01T12:00:00+00:00 |
| RFC 2822 / 1123 | Date format common in HTTP headers | Fri, 01 Sep 2023 12:00:00 GMT |
| YYYY-MM-DD | Date only (ISO date) | 2023-09-01 |
| YYYY/MM/DD | Slash-separated date (Chinese convention) | 2023/09/01 |
| YYYY年M月D日 | Chinese long date | 2023年9月1日 |
| HH:mm:ss | 24-hour time | 12:00:00 |
| hh:mm A | 12-hour time with AM/PM | 12:00 PM |
| YYYY-MM-DD HH:mm:ss | Common database datetime | 2023-09-01 12:00:00 |
| 相对时间 | e.g. "3 minutes ago", for social/log display | 3 minutes ago |
| 季度 Qn-YYYY | Fiscal/quarter representation | Q3-2023 |
| ISO 周 Www-yyyy | ISO week number | W35-2023 |
| Duration(ISO 8601) | Time duration notation | P1Y2M3DT4H5M6S |
| 毫秒时间戳 | Value returned by JavaScript Date.now() | 1693564800000 |
Frequently Asked Questions
Is a Unix timestamp seconds or milliseconds?
Usually seconds (e.g. 1693564800), but JavaScript Date.now() and many frontend libs return milliseconds (13 digits). Confirm the unit when interoperating, converting with ×1000 or ÷1000 as needed — otherwise you get a 1000x error landing in 1970 or the year 50000.
What is the difference between ISO 8601 and RFC 3339?
RFC 3339 is a strict subset of ISO 8601: it requires a full date-time, a timezone (Z or ±hh:mm), and forbids a space between date and time. Prefer RFC 3339 for APIs — it is the most unambiguous.
What is the relationship between UTC, GMT and +08:00?
UTC and GMT are effectively equal in daily use (GMT is a timezone name, UTC a time standard). +08:00 means 8 hours ahead of UTC (e.g. China Standard Time). Store times in UTC (or with offset) and convert to the user's zone only for display.
Which time format should databases store?
Prefer native datetime/timestamp types in relational databases (the DB handles timezone and format). If storing as a string, use ISO 8601/RFC 3339 with an explicit timezone, avoiding ambiguous "2023-09-01 12:00" without zone.