Date Format Notation
- Date: 2024-01-01 09:01:01 PM 123
- Case sensitive.
Code | Description | Example |
---|---|---|
yyyy | 4 digits for year | 2024 |
yy | Last 2 digits for year | 24 |
y | Last 1 digit for year | 4 |
MM | 2 digits for month with 0 | 01 |
M | 1~2 digits for month | 1 |
dd | 2 digits for day with 0 | 01 |
d | 1~2 digits for day | 1 |
hh | 2 digits for 12-hour format | 09 |
h | 1~2 digits for 12-hour format | 9 |
HH | 2 digits for 24-hour format | 21 |
H | 1~2 digits for 24-hour format | 21 |
mm | 2 digits for minute | 01 |
m | 1~2 digits for minute | 1 |
ss | 2 digits for second | 01 |
s | 1~2 digits for second | 1 |
fff | millisecond | 123 |
tt | 2 digits for AM, PM | PM |
t | 1 digit for AM, PM | P |
Conclusion
I've organized the C# date format.
More formats
There are more formats if you access the MS site.