A date and time format string specifies how a DateTime or DateTimeOffset value is represented as text during a formatting operation. It can also determine how a date and time value should be formatted when parsing a string to convert it back into a date and time object. Custom format strings are made up of one or more custom date and time format specifiers. Any string that doesn’t follow the standard format is treated as a custom date and time format string.
A standard date and time format string consists of a single character that serves as the format specifier to define how a DateTime or DateTimeOffset value is displayed as text. If the format string contains more than one character, including spaces, it is considered a custom date and time format string.
Format | Output |
DateTime.Now.ToString("MM/dd/yyyy") | 10/13/2024 |
DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss") | Sunday, 13 Oct 2024 11:54:06 |
DateTime.Now.ToString("MM/dd/yyyy HH:mm") | 10/13/2024 11:54 |
DateTime.Now.ToString("MM/dd/yyyy hh:mm tt") | 10/13/2024 11:54 AM |
DateTime.Now.ToString("MM/dd/yyyy H:mm") | 10/13/2024 6:54 |
DateTime.Now.ToString("MM/dd/yyyy h:mm tt") | 10/13/2024 6:54 AM |
DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") | 10/13/2024 11:54:06 |
DateTime.Now.ToString("MMMM dd") | Oct 13 |
DateTime.Now.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss.fffffffK") | 2024-10-13T11:54:06.7199222-04:00 |
DateTime.Now.ToString("ddd, dd MMM yyy HH’:’mm’:’ss ‘GMT’") | Sun, 13 Oct 2024 11:54:06 GMT |
DateTime.Now.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss") | 2024-10-13T11:54:06 |
DateTime.Now.ToString("HH:mm") | 11:54 |
DateTime.Now.ToString("hh:mm tt") | 11:54 AM |
DateTime.Now.ToString("H:mm") | 6:54 |
DateTime.Now.ToString("h:mm tt") | 6:54 AM |
DateTime.Now.ToString("HH:mm:ss") | 11:54:06 |
DateTime.Now.ToString("yyyy MMMM") | 2024 Oct |
Definition of Format Specifier
Format Specifier | Definition |
d | The day of the month, from 1 to 31 |
dd | The day of the month, from 01 to 31. |
ddd | The abbreviated name of the day of the week - Mon (en-US). |
dddd | The full name of the day of the Week - Monday (en-US). |
h | hour, 12-hour clock from 1 to 12 2024-10-13T05:54:40 → 5 |
hh | hour, 12-hour clock from 01 to 12 2024-10-13T05:54:40 → 05 |
H | hour, 24-hour clock from 01 to 12 2024-10-13T05:54:40 → 5 |
HH | hour, 24-hour clock from 01 to 12 2024-10-13T13:54:40 → 13 |
m | minute, from 0-59, 2024-10-13T13:09:40 → 9 |
mm | minute, from 00-59, 2024-10-13T13:09:40 → 09 |
M | month, from 1-12, 2024-06-13T13:09:40 → 6 |
MM | month, from 01-12, 2024-06-13T13:09:40 → 06 |
MMM | abbreviated name of the month, 2024-10-13T13:54:40 → Oct |
MMMM | full name of the month, 2024-10-13T13:54:40 → October |
s | second, from 0-59, 2024-10-13T13:54:06 → 6 |
ss | second, from 00-59, 2024-10-13T13:54:06 → 06 |
t | first character of the AM/PM , 2024-10-13T13:54:06 → P |
tt | the AM/PM, 2024-10-13T13:54:06 → PM |
y | year, 0-99, 0001-10-13T13:54:06 → 1, 2024-10-13T13:54:06 → 24 |
yy | year, 00-99, 0001-10-13T13:54:06 → 01, 2024-10-13T13:54:06 → 24 |
yyy | year, minimum of 3 digits, 0001-10-13T13:54:06 → 001, 2024-10-13T13:54:06 → 2024 |
yyyy | year, 4 digit number, 0001-10-13T13:54:06 → 0001, 2024-10-13T13:54:06 → 2024 |
f | The tenths of a second in a date and time value 2024-10-13T14:54:40.7190000 → 7 2024-10-13T14:54:40.01 → 0 |
ff | The hundredths of a second in a date and time value 2024-10-13T14:54:40.7190000 → 71 2024-10-13T14:54:40.009 → 00 |
fff | The milliseconds in a date and time value 2024-10-13T14:54:40.719 → 719 2024-10-13T14:54:40.0005 → 000 |
ffff | The ten-thousandths of a second in a date and time value 2024-10-13T14:54:40.7195000 → 7195 2024-10-13T14:54:40.0000500 → 0000 |
fffff | The hundred-thousandths of a second in a date and time value 2024-10-13T14:54:40.7195200 → 71952 2024-10-13T14:54:40.0000050 → 00000 |
ffffff | The millionths of a second in a date and time value 2024-10-13T14:54:40.7195210 → 719521 2024-10-13T14:54:40.0000005 → 000000 |
fffffff | The ten-millionths of a second in a date and time value 2024-10-13T14:54:40.7195212 → 7195212 2024-10-13T14:54:40.0001250 → 0001250 |
F | If non-zero, the tenths of a second in a date and time value 2024-10-13T14:54:40.7190000 → 7 2024-10-13T14:54:40.0100000 → (no output) |
FF | If non-zero, the hundredths of a second in a date and time value 2024-10-13T14:54:40.7190000 → 71 2024-10-13T14:54:40.0090000 → (no output) |
FFF | If non-zero, the milliseconds in a date and time value 2024-10-13T14:54:40.719 → 719 2024-10-13T14:54:40.0005000 → (no output) |
FFFF | If non-zero, the ten-thousandths of a second in a date and time value 2024-10-13T14:54:40.7195000 → 7195 2024-10-13T14:54:40.0000500 → (no output) |
FFFFF | if non-zero, the hundred-thousandths of a second in a date and time value 2024-10-13T14:54:40.7195200 → 71952 2024-10-13T14:54:40.0000050 → (no output) |
FFFFFF | If non-zero, the millionths of a second in a date and time value 2024-10-13T14:54:40.7195210 → 719521 2024-10-13T14:54:40.0000005 → (no output) |
FFFFFFF | If non- zero, the ten-millionths of a second in a date and time value 2024-10-13T14:54:40.7195212 → 7195212 2024-10-13T14:54:40.0001250 → 0001250 |
How Memetic Solutions Enhances User Experience
At Memetic Solutions, we use these notification permission concepts to keep applications user-friendly. By ensuring users control their settings, we create apps that are both intuitive and engaging, improving user satisfaction without disrupting their experience.