Name
TimeFormat
Synopsis
TimeFormat(time
[,mask
])
Returns time
formatted according to
mask
. If no value is specified for
mask
, TimeFormat( )
uses the default hh:mm tt
. Valid entries for
mask
are:
Mask |
Description |
---|---|
h |
Hours based on a 12-hour clock with no leading zeros for single-digit hours |
hh |
Hours based on a 12-hour clock with leading zeros for single-digit hours |
H |
Hours based on a 24-hour clock with no leading zeros for single-digit hours |
HH |
Hours based on a 24-hour clock with leading zeros for single-digit hours |
m |
Minutes with no leading zero for single-digit minutes |
mm |
Minutes with a leading zero for single-digit minutes |
s |
Seconds with no leading zero for single-digit seconds |
ss |
Seconds with a leading zero for single-digit seconds |
l |
Milliseconds with no leading zeros for single or double-digit milliseconds |
t |
Single-character meridian, either A or p |
tt |
Multicharacter meridian, either AM or PM |
short |
Java short time format |
medium |
Java medium time format |
long |
Java long time format |
full |
Java full date format: |
If an invalid mask is passed to the function, ColdFusion outputs the invalid characters. Examples:
<cfset TheTime = Now( )> <cfoutput> TheTime = #TimeFormat(TheTime,'hh:mm:ss tt')#<p> TimeFormat(TheTime, 'h:m:s'): #TimeFormat(TheTime, 'h:m:s')#<br> TimeFormat(TheTime, 'h:m:s t'): #TimeFormat(TheTime, 'h:m:s t')#<br> TimeFormat(TheTime, 'hh:mm:ss'): #TimeFormat(TheTime, 'hh:mm:ss')#<br> TimeFormat(TheTime, 'hh:mm:ss tt'): #TimeFormat(TheTime, ...
Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.