0% found this document useful (0 votes)
3 views6 pages

C# Date and Time Format Specifiers

Uploaded by

Madhuri Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

C# Date and Time Format Specifiers

Uploaded by

Madhuri Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

STANDARD DATE AND

TIME FORMAT SPECIFIERS


IN C#
DATE AND TIME FORMAT
SPECIFIERS
• A date and time format specifier is a special character that enables
you to display the date and time values in different formats.
• Format Specifier Name
• d Short date
• D Long date
• f Full date/time
(short time)
• F Full date/time
(long time)
• g General
DATE AND TIME FORMAT
SPECIFIERS
Syntax:
• DateTime dt = [Link];
• [Link]("{0:D}", dt);
• [Link]("{0:f}", dt);
• [Link]("{0:F}", dt);
• [Link]("{0:g}", dt);
• [Link]("{0:d} {1:D}", dt, dt);
DATE AND TIME FORMAT
SPECIFIERS
• Format Specifier Name
• G General
date/time (long time)
• m or M Month day
• t Short
time
• T Long time
• y or Y Year month pattern
DATE AND TIME FORMAT
SPECIFIERS
• Format Specifier Name
• ddd Represents the abbreviated
name of the day of the week.
• dddd Represents the full name of the day of
the week.
• FF Represents the two digits of the
seconds fraction
• HH Represents the hour from 00 to
23
• MM Represents the month as a
number from 01 to 12
• MMM Represents the abbreviated name of the
month
• ss Represents the seconds as a
number from 0 to 59
DATE AND TIME FORMAT
SPECIFIERS

• [Link]("{0:HH:mm:ss tt}", dt);


• [Link]("{0:dd-MM-yyyy}", dt);

You might also like