Date formatting in various programming languages and systems can vary, but here’s a cheat sheet with commonly used date format patterns:
ISO 8601 Date and Time Format
Format:
YYYY-MM-DDTHH:mm:ss
Example:
2022-01-01T12:30:45
Short Date Format
Format:
MM/DD/YYYY
Example:
01/01/2022
Long Date Format
Format:
Month DD, YYYY
Example:
January 01, 2022
Time Format – 24-hour clock
Format:
HH:mm:ss
Example:
12:30:45
Time Format – 12-hour clock with AM/PM
Format:
h:mm:ss A
Example:
12:30:45 PM
Month and Year
Format:
MMM YYYY
Example:
Jan 2022
Day of the Week, Month, Day, and Year
Format:
ddd, MMM DD, YYYY
Example:
Sat, Jan 01, 2022
Custom Format with Short Day and Month Names
Format:
d-MMM-YYYY
Example:
1-Jan-2022
RFC 2822 Date Format
Format:
Day, DD Mon YYYY HH:mm:ss ZZ
Example:
Sat, 01 Jan 2022 12:30:45 +0000
Unix Timestamp (Seconds since Epoch)
Format:
%s
Example:
1641052245
Long Date Format with Time Zone
Format:
dddd, MMMM DD, YYYY HH:mm:ss Z
Example:
Saturday, January 01, 2023 12:30:45 UTC
Week Number
Format:
WW
Example:
01
Note
- Formats can vary based on programming languages and libraries.
- Always refer to the documentation of the specific language or library you are working with for accurate and language-specific date format options.
This cheat sheet provides examples for common date formats, but be sure to adjust based on your specific requirements and the capabilities of the programming language or system you are using.