Formats a time value using US English time formatting conventions. If no mask is specified, returns a time value using the hh:mm tt format. For international time formatting, see LSTimeFormat.
timeFormat(time [, mask])
→ returns string
time.timeFormat([mask])
hh:mm tt
h
,hh
: Hours in 12 hour formatH
,HH
: Hours in 24 hour formatm
,mm
: Minutess
,ss
: Secondsl
: Millisecondst
: A or Ptt
: AM or PMz
: Time zone in literal format, for example GMTZ
: Time zone in hours offset (RFC822), for example +0400X
,XX
,XXX
: Time zone in hours of offset in ISO 8601 format"short"
: h:mm tt
"medium"
: h:mm:ss tt
short
medium
long
full
z
Z
and X
masks were added in CF2016+
timeFormat( createDateTime(2017, 8, 31, 15, 25, 11), "h:mm tt")
Expected Result: 3:25 PM
Requires CF 11+ or Lucee 5+
createDateTime(2017, 8, 31, 15, 25, 11).timeFormat("h:mm tt")
Expected Result: 3:25 PM
Should default mask to hh:mm tt
timeFormat( createDateTime(2017, 8, 31, 15, 25, 11) )
Expected Result: 03:25 PM
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.