Show Menu
Cheatography

.NET Standard DateTime Format Strings Cheat Sheet by

Years

y
Represents the year as at most a two-digit number. If the year has more than two digits, only the two low-order digits appear in the result. If the year has fewer than two digits, the number is formatted without a leading zero.
yy
Represents the year as a two-digit number. If the year has more than two digits, only the two low-order digits appear in the result. If the year has fewer than two digits, the number is padded with leading zeroes to achieve two digits.
yyy
Represents the year as a three-­digit number. If the year has more than three digits, only the three low-order digits appear in the result. If the year has fewer than three digits, the number is padded with leading zeroes to achieve three digits. Note that for the Thai Buddhist calendar, which can have five-digit years, this format specifier displays all five digits.
yyyy
Represents the year as a four-digit number. If the year has more than four digits, only the four low-order digits appear in the result. If the year has fewer than four digits, the number is padded with leading zeroes to achieve four digits. Note that for the Thai Buddhist calendar, which can have five-digit years, this format specifier renders all five digits.
yyyyy
Represents the year as a five-digit number. If the year has more than five digits, only the five low-order digits appear in the result. If the year has fewer than five digits, the number is padded with leading zeroes to achieve five digits. If there are additional "­y" specif­iers, the number is padded with as many leading zeroes as necessary to achieve the number of "­y" specif­iers.
 

Months

M
Represents the month as a number from 1 through 12. A single­-digit month is formatted without a leading zero.
MM
Represents the month as a number from 01 through 12. A single­-digit month is formatted with a leading zero.
MMM
Represents the abbrev­iated name of the month as defined in the current System.Gl­oba­liz­ati­on.D­at­eTi­meF­orm­atI­nfo.Ab­bre­via­ted­Mon­thNames property.
MMMM
Represents the full name of the month as defined in the current System.Gl­oba­liz­ati­on.D­at­eTi­meF­orm­atI­nfo.Mo­nth­Names property.

Days

d
Represents the day of the month as a number from 1 through 31. A single­-digit day is formatted without a leading zero.
dd
Represents the day of the month as a number from 01 through 31. A single­-digit day is formatted with a leading zero.
ddd
Represents the abbrev­iated name of the day of the week as defined in the current System.Gl­oba­liz­ati­on.D­at­eTi­meF­orm­atI­nfo.Ab­bre­via­ted­Day­Names property.
dddd
Represents the full name of the day of the week as defined in the current System.Gl­oba­liz­ati­on.D­at­eTi­meF­orm­atI­nfo.Da­yNames property.
               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Numeric Formats Cheat Sheet
          H10 Klassen & Objecten Cheat Sheet