Net Standard Datetime Format Strings Page 2

ADVERTISEMENT

.NET Custom DateTime Format Strings
Specifier
Description
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 abbreviated name of the day of the week as defined in the current System.Globalization.DateTimeFormatInfo.AbbreviatedDayNames property.
dddd
Represents the full name of the day of the week as defined in the current System.Globalization.DateTimeFormatInfo.DayNames property.
f
Represents the most significant digit of the seconds fraction.
Note that if the "f" format specifier is used alone, without other format specifiers, it is interpreted as the "f" standard DateTime format specifier (full date/time pattern).
When you use this format specifier with the ParseExact or TryParseExact method, the number of "f" format specifiers that you use indicates the number of most significant digits of the
seconds fraction to parse.
ff…
Number of repeated specifiers represents most significant digits of the seconds fraction.
F
Represents the most significant digit of the seconds fraction. Nothing is displayed if the digit is zero.
When you use this format specifier with the ParseExact or TryParseExact method, the number of "F" format specifiers that you use indicates the maximum number of most significant
digits of the seconds fraction to parse.
FF…
Number of repeated specifiers represents most significant digits of the seconds fraction. Trailing zeros, or two zero digits, are not displayed.
g or gg
Represents the period or era (A.D. for example). This specifier is ignored if the date to be formatted does not have an associated period or era string.
h
Represents the hour as a number from 1 through 12, that is, the hour as represented by a 12-hour clock that counts the whole hours since midnight or noon.
A single-digit hour is formatted without a leading zero.
hh
Represents the hour as a number from 01 through 12, that is, the hour as represented by a 12-hour clock that counts the whole hours since midnight or noon.
A single-digit hour is formatted with a leading zero.
H
Represents the hour as a number from 0 through 23, that is, the hour as represented by a zero-based 24-hour clock that counts the hours since midnight.
A single-digit hour is formatted without a leading zero.
HH
Represents the hour as a number from 00 through 23, that is, the hour as represented by a zero-based 24-hour clock that counts the hours since midnight.
A single-digit hour is formatted with a leading zero.
K
Represents different values of the DateTime.Kind property, that is, Local, Utc, or Unspecified. This specifier round-trips the kind value in text and preserves the time zone. For the Local
kind value, this specifier is equivalent to the "zzz" specifier and displays the local offset, for example, "-07:00". For the Utc kind value, the specifier displays a "Z" character to represent
a UTC date. For the Unspecified kind value, the specifier is equivalent to "" (nothing).
m
Represents the minute as a number from 0 through 59. The minute represents whole minutes passed since the last hour.
A single-digit minute is formatted without a leading zero.
mm
Represents the minute as a number from 00 through 59. The minute represents whole minutes passed since the last hour.
A single-digit minute is formatted with a leading zero.
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 abbreviated name of the month as defined in the current System.Globalization.DateTimeFormatInfo.AbbreviatedMonthNames property.
MMMM
Represents the full name of the month as defined in the current System.Globalization.DateTimeFormatInfo.MonthNames property.
More .NET Cheat Sheets available at

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 6