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.
| 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.