Show Menu

Date/Time Formats Cheat Sheet by

Characters used to export dates in a desired format
format     formatting     vb

Predefined Date/Time Formats

R or r
Formats the date according to the RFC112­3Pa­ttern property.
For example, Sun, 02 Mar 2008 16:07:04 GMT
The formatted date does not adjust the value of the date and time.
You must adjust the Date/Time value to GMT before calling the Format function
U
Formats the date and time with the long date and long time as GMT.
For example, 02 March 2008 16:07:04
F
Displays the Long Date and Long Time according to your current culture's format.
For example, 02 March 2008 16:07:04
f
Displays the Long Date and Short Time according to your current culture's format.
For example, 02 March 2008 16:07
G
General Date
Displays a date and/or time.
For example, 02/0­3/2008 16:07:04
Date display is determined by your applic­ation's current culture value
g
Displays the Short Date and Short Time according to your current culture's format.
For example, 02/0­3/2008 16:07
D
Long Date
Displays a date according to your current culture's Long Date format.
For example, 02 March 2008
d
Short Date
Displays a date using your current culture's Short Date format.
For example, 02/0­3/2­008
M or m
Displays the month and the day of a date.
For example, 02 March
Y or y
Formats the date as the year and month.
For example, March 2008
T
Long Time
Displays a time using your current culture's Long Time format; typically includes hours, minutes, seconds.
For example, 16:0­7:04
t
Short Time
Displays a time using your current culture's Short Time format.
For example, 16:07
s
Formats the date and time as a sortable index.
For example, 2008­-03­-02­T16­:07­:04
u
Formats the date and time as a GMT sortable index.
For example, 2008­-03-02 16:07:­04Z
The examples were created on a machine with 'English (United Kingdom)' Region settings
Uses 2nd of March 2008 16:07:04 GMT as the example Date & Time

User-D­efined Date/Time Formats

:
Time separator
In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character that is used as the time separator in formatted output is determined by your applic­ation's current culture value.
/
Date separator
In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character that is used as the date separator in formatted output is determined by your applic­ation's current culture.
%
Used to indicate that the following character should be read as a single­-letter format without regard to any trailing letters. Also used to indicate that a single­-letter format is read as a user-d­efined format. See what follows for additional details .
d
Displays the Day as a number without a leading zero
For example, 2
Use %d if this is the only character in your user-d­efined numeric format.
dd
Displays the Day as a number with a leading zero
For example, 02
ddd
Displays the Day as an abbreviation
For example, Sun
dddd
Displays the Day as a full name
For example, Sunday
M
Displays the Month as a number without a leading zero
For example, 3
Use %M if this is the only character in your user-d­efined numeric format.
MM
Displays the Month as a number with a leading zero
For example, 03
MMM
Displays the Month as an abbreviation
For example, Mar
MMMM
Displays the Month as a full month name
For example, March
y
Displays the Year as a number without leading zeros.
For exmaple, 8
Use %y if this is the only character in your user-d­efined numeric format.
yy
Displays the Year in two-digit numeric format with a leading zero, if applicable.
For example, 08
yyy
Displays the year in four-digit numeric format.
For example, 2008
yyyy
Displays the year in four-digit numeric format.
For example, 2008
gg
Displays the period/era string
For example, A.D.
h
Displays the Hour as a number without leading zeros using the 12-hour clock
For example, 4
Use %h if this is the only character in your user-d­efined numeric format.
hh
Displays the Hour as a number with leading zeros using the 12-hour clock
For example, 04
H
Displays the Hour as a number without leading zeros using the 24-hour clock
For example, 16
Use %H if this is the only character in your user-d­efined numeric format.
HH
Displays the Hour as a number with leading zeros using the 24-hour clock
For example, 16
m
Displays the Minute as a number without leading zeros
For example, 7
Use %m if this is the only character in your user-d­efined numeric format.
mm
Displays the Minute as a number with leading zeros
For example, 07
s
Displays the Second as a number without leading zeros
For example, 4
Use %s if this is the only character in your user-d­efined numeric format.
ss
Displays the Second as a number with leading zeros
For example, 04
f
Displays fractions of seconds.
For example ff displays hundredths of seconds, whereas ffff displays ten-th­ous­andths of seconds. You may use up to seven f symbols in your user-d­efined format.
Use %f if this is the only character in your user-d­efined numeric format.
t
Uses the 12-hour clock and displays an uppercase 'A' for any hour before noon; displays an uppercase ''P'' for any hour between noon and 11:59 P.M.
For example, P
Use %t if this is the only character in your user-d­efined numeric format.
tt
For locales that use a 12-hour clock, displays an uppercase 'AM' with any hour before noon; displays an uppercase 'PM' with any hour between noon and 11:59 P.M.
For example, PM
For locales that use a 24-hour clock, displays nothing.
z
Displays the timezone offset without a leading zero
For example, +0
Use %z if this is the only character in your user-d­efined numeric format.
zz
Displays the timezone offset with a leading zero
For example, +00
zzz
Displays the full timezone offset
For example, +00:00
Uses 2nd of March 2008 16:07:04 GMT as the example Date & Time

Download the Date/Time Formats Cheat Sheet

4 Pages
//media.cheatography.com/storage/thumb/pezmat_date-time-formats.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Numeric Formats Cheat Sheet
          Slack messages formatting Cheat Sheet

          More Cheat Sheets by PezMat

          Numeric Formats Cheat Sheet