Date & Time Format Cheatsheet - Date Formatting & Timestamp Reference
Date bugs are usually timezone bugs — a timestamp that looks right locally is off by 8 hours elsewhere. Organized by strftime tokens, ISO 8601, timezones/offsets, per-language methods and timestamp conversion, this table lets you map a token to its output and avoid the classic UTC vs local pitfall. Use it when formatting logs, building API timestamps, or parsing ISO strings. After reading you pick a format that round-trips consistently across servers and clients.
strftime Format Specifiers 13
%Y%y%m%d%H%I%M%S%p%A%B%Z%sISO 8601 Standard 7
2024-01-152024-01-15T10:30:00Z2024-01-15T10:30:00+08:002024-01-15T10:30:00.123Z2024-W03-12024-015PT1H30MTimezone & Offset 6
UTCGMT+08:00Asia/ShanghaiAmerica/New_YorkDSTDate Formatting by Language 7
new Date().toISOString()datetime.now().strftime("%Y-%m-%d")date("+%Y-%m-%d %H:%M:%S")SimpleDateFormat("yyyy-MM-dd")time.Now().Format("2006-01-02")chrono::Local::now()Intl.DateTimeFormat().format()Timestamp Conversion 6
Date.now()int(time.time())date +%snew Date(1705312200 * 1000)datetime.fromtimestamp(1705312200)date -d @1705312200Date Arithmetic 6
now + timedelta(days=7)new Date(Date.now() + 86400000)date -d "+1 days"d1 > d2(d2 - d1).daysdayjs(d1).isAfter(d2)Common Date Formats 5
2024-01-15 10:30:00Mon, 15 Jan 2024 10:30:00 GMT2024/01/15202401151705312200Tips
- ISO 8601 is the international standard — use it consistently in APIs and databases.
- Go's reference time is 2006-01-02 15:04:05 (Mon Jan 2 15:04:05 MST 2006).
- Unix timestamp is seconds (10 digits); JavaScript Date.now() is milliseconds (13 digits).
- For timezones, store in UTC and convert to local only when displaying.
- Java's SimpleDateFormat is not thread-safe; use DateTimeFormatter in multithreaded code.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us