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

t

Single-character meridian, either A or P

tt

Multicharacter meridian, either AM or PM

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, 'hh:mm:ss tt')#<BR>
TimeFormat(TheTime, 'H:M:ss'): #TimeFormat(TheTime, 'H:M:s')#<BR>
TimeFormat(TheTime, 'HH:MM:ss'): #TimeFormat(TheTime, 'HH:MM:ss')#<BR>
</CFOUTPUT>

Get Programming ColdFusion 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.