[Previous][Up][Next] Reference for unit 'sysutils' (#rtl)

Date and time formatting characters

Various date and time formatting routines accept a format string to format the date and or time. The following characters can be used to control the date and time formatting:

c
Formats date using shortdateformat and formats time using longtimeformat if the time is not zero.
f
Same as c, but adds the time even if it is zero.
d
day of month
dd
day of month (leading zero)
ddd
day of week (abbreviation)
dddd
day of week (full)
ddddd
shortdateformat
dddddd
longdateformat
m
month or minutes if preceded by h or hh specifiers.
mm
month or minutes if preceded by h or hh specifiers, with leading zero.
mmm
month (abbreviation)
mmmm
month (full)
y
year (2 digits)
yy
year (two digits)
yyyy
year (with century)
h
hour
hh
hour (leading zero)
n
minute
nn
minute (leading zero)
s
second
ss
second (leading zero)
t
shorttimeformat
tt
longtimeformat
am/pm
use 12 hour clock and display am and pm accordingly
a/p
use 12 hour clock and display a and p accordingly
/
insert date seperator
:
insert time seperator
"xx"
literal text
'xx'
literal text
z
milliseconds
zzz
milliseconds(leading zero)
[h]
hours including the hours of the full days (i.e. can be > 24).
[hh]
hours with leading zero, including the hours of the full days (i.e. can be > 24)
[n]
minutes including the minutes of the full hours and days
[nn]
minutes with leading zero, including the minutes of the full hours and days
[s]
seconds including the seconds of the full minutes, hours and days.
[ss]
seconds with leading zero, including the seconds of the full minutes, hours and days.

The forms in square brackets are only allowed if the fdPeriod option is included in the Options argument of FormatDateTime.

The date and time separators are taken from the DefaultFormatSettings record, unless a TFormatSettings record is passed to the FormatDateTime function.

Note that to include any of the above characters literally in the result string, they must be enclosed in double quotes.

See also

DefaultFormatSettings

  

Storage for default settings

TFormatSettings

  

Record with all the strings that determine formatting

FormatDateTime

  

Return a string representation of a TDateTime value with a given format.


Documentation generated on: Sep 28 2017