HomeGuidesRecipesAPI
HomeGuidesAPILog In
Guides
These docs are for v10. Click to read the latest docs for v31.

Custom date/time format strings

Use the following table to create custom date/time format strings:

FormatDescription
[:]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 used as the time separator in formatted output is determined by your system's LocaleID 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 used as the date separator in formatted output is determined by your locale.
[%]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-defined format. See below for further details.
dDisplays the day as a number without a leading zero (for example, 1). Use %d if this is the only character in your user-defined numeric format.
ddDisplays the day as a number with a leading zero (for example, 01).
dddDisplays the day as an abbreviation (for example, Sun).
ddddDisplays the day as a full name (for example, Sunday).
MDisplays the month as a number without a leading zero (for example, January is represented as 1). Use %M if this is the only character in your user-defined numeric format.
MMDisplays the month as a number with a leading zero (for example, 01/12/01).
MMMDisplays the month as an abbreviation (for example, Jan).
MMMMDisplays the month as a full month name (for example, January).
ggDisplays the period/era string (for example, A.D.)
hDisplays the hour as a number without leading zeros using the 12-hour clock (for example, 1:15:15 PM). Use %h if this is the only character in your user-defined numeric format.
hhDisplays the hour as a number with leading zeros using the 12-hour clock (for example, 01:15:15 PM).
HDisplays the hour as a number without leading zeros using the 24-hour clock (for example, 1:15:15). Use %H if this is the only character in your user-defined numeric format.
HHDisplays the hour as a number with leading zeros using the 24-hour clock (for example, 01:15:15).
mDisplays the minute as a number without leading zeros (for example, 12:1:15). Use %m if this is the only character in your user-defined numeric format.
mmDisplays the minute as a number with leading zeros (for example, 12:01:15).
sDisplays the second as a number without leading zeros (for example, 12:15:5). Use %s if this is the only character in your user-defined numeric format.
ssDisplays the second as a number with leading zeros (for example, 12:15:05).
FDisplays fractions of seconds. For example ff will display hundredths of seconds, whereas ffff will display ten-thousandths of seconds. You may use up to seven f symbols in your user-defined format. Use %f if this is the only character in your user-defined numeric format.
TUses 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. Use %t if this is the only character in your user-defined numeric format.
ttUses the 12-hour clock and displays an uppercase AM with any hour before noon; displays an uppercase PM with any hour between noon and 11:59 P.M.
yDisplays the year number (0-9) without leading zeros. Use %y if this is the only character in your user-defined numeric format.
yyDisplays the year in two-digit numeric format with a leading zero, if applicable.
yyyDisplays the year in four digit numeric format.
yyyyDisplays the year in four digit numeric format.
zDisplays the timezone offset without a leading zero (for example, -8). Use %z if this is the only character in your user-defined numeric format.
zzDisplays the timezone offset with a leading zero (for example, -08)
zzzDisplays the full timezone offset (for example, -08:00)