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.

FormatMeaningExample
Unix 时间戳Seconds (or ms) since 1970-01-01 UTC1693564800
ISO 8601ISO date-time format2023-09-01T12:00:00Z
ISO 8601(含时区偏移)Local time with +08:00 style offset2023-09-01T20:00:00+08:00
RFC 3339Strict subset of ISO 8601, common in APIs2023-09-01T12:00:00+00:00
RFC 2822 / 1123Date format common in HTTP headersFri, 01 Sep 2023 12:00:00 GMT
YYYY-MM-DDDate only (ISO date)2023-09-01
YYYY/MM/DDSlash-separated date (Chinese convention)2023/09/01
YYYY年M月D日Chinese long date2023年9月1日
HH:mm:ss24-hour time12:00:00
hh:mm A12-hour time with AM/PM12:00 PM
YYYY-MM-DD HH:mm:ssCommon database datetime2023-09-01 12:00:00
相对时间e.g. "3 minutes ago", for social/log display3 minutes ago
季度 Qn-YYYYFiscal/quarter representationQ3-2023
ISO 周 Www-yyyyISO week numberW35-2023
Duration(ISO 8601)Time duration notationP1Y2M3DT4H5M6S
毫秒时间戳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.