C# DateTime Formatters (most common)


DateTime
.Now.ToUniversalTime().ToString("MMddyyyy", CultureInfo.InvariantCulture)

Day Formatters

d – Represents the day of the month as a number from 1 through 31

dd – Represents the day of the month as a number from 01 through 31

ddd – Represents the abbreviated name of the day of the week

dddd – Represents the full name of the day of the week

Month Formatters

M – Represents the month as a number from 1 through 12

MM – Represents the month as a number from 01 through 12

MMM – Represents the abbreviated name of the month

MMMM -Represents the full name of the month

Year Formatters

y – Represents the year as a one or two-digit number

yy – Represents the year as a two-digit number

yyy – Represents the year with a minimum of three digits

yyyy – Represents the year as a four-digit number

yyyyy – Represents the year as a five-digit number

Hour Formatters

h – Represents the hour as a number from 1 through 12

hh – Represents the hour as a number from 01 through 12

H – Represents the hour as a number from 0 through 23

HH – Represents the hour as a number from 00 through 23

Minute Formatters

m – Represents the minute as a number from 0 through 59

mm – Represents the minute as a number from 00 through 59

Second Formatters

s – Represents the seconds as a number from 0 through 59

ss – Represents the seconds as a number from 00 through 59

Time of Day Formatters

t – Represents the first character of the AM/PM designator

tt – Represents the AM/PM designator

: – Represents the time separator

/ – Represents the date separator

Published by

Tim Clark

Experienced Business Owner, Chief Information Officer, Vice President, Chief Software Architect, Application Architect, Project Manager, Software Developer, Senior Web Developer, Graphic Designer & 3D Modeler, University Instructor, University Program Chair, Academic Director. Specialties: Ruby, Ruby on Rails, JavaScript, JQuery, AJAX, Node.js, React.js, Angular.js, MySQL, PostgreSQL, MongoDB, SQL Server, Responsive Design, HTML5, XHTML, CSS3, C#, ASP.net, Project Management, System Design/Architecture, Web Design, Web Development, Adobe CS6 (Photoshop, Illustrator)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s