Monday, February 22, 2016

DateTime Formatting

DateTime Formatting


DateTime is a structureof value Type like int, double etc. It is available in System namespace and present in mscorlib.dll assembly. It implements interfaces like IComparable, IFormattable, IConvertible, ISerializable, IComparable, IEquatable.

Different users need different kind format date. For instance some users need date like "mm/dd/yyyy", some need "dd-mm-yyyy". So below specifiers will help you to get date in different formats. Let's say current Date Time is "12/8/2015 3:15:19 PM" and as per that you will get output based on specifier.



Specifier Description Output
d Short Date 12/8/2015
D Long Date Tuesday, December 08, 2015
t Short Time 3:15 PM
T Long Time 3:15:19 PM
f Full date and time Tuesday, December 08, 2015 3:15 PM
F Full date and time (long) Tuesday, December 08, 2015 3:15:19 PM
g Default date and time 12/8/2015 15:15
G Default date and time (long) 12/8/2015 15:15
M Day / Month 8-Dec
r RFC1123 date Tue, 08 Dec 2015 15:15:19 GMT
s Sortable date/time 2015-12-08T15:15:19
u Universal time, local timezone 2015-12-08 15:15:19Z
Y Month / Year December, 2015
dd Day 8
ddd Short Day Name Tue
dddd Full Day Name Tuesday
hh 2 digit hour 3
HH 2 digit hour (24 hour) 15
mm 2 digit minute 15
MM Month 12
MMM Short Month name Dec
MMMM Month name December
ss seconds 19
fff milliseconds 120
FFF milliseconds without trailing zero 12
tt AM/PM PM
yy 2 digit year 15
yyyy 4 digit year 2015
: Hours, minutes, seconds separator, e.g. {0:hh:mm:ss} 9:08:59
/ Year, month , day separator, e.g. {0:dd/MM/yyyy} 8/4/2007

1 comment:

  1. Design, develop and implement applications that support day-to-day operations.

    Provide innovative solutions to complex business problems.

    Plan, develop and implement large-scale projects from conception to completion.

    Develop and architect lifecycle of projects working on different technologies and platforms.

    Interface with clients and gather business requirements and objectives.

    Translate clients’ business requirements and objectives into technical applications and solutions.

    Understand and evaluate complex data models.

    Design, develop and implement new integration.

    Execute system development and maintenance activities.

    Develop solutions to improvise performance and scalability of systems.

    ReplyDelete