lsTimeFormat

Formats the time part of a date/time string into a string in a locale-specific format.
[mask - quicky]
h,hh,H,HH: Hours; m,mm: Minutes; s,ss: Seconds;
l: Milliseconds; t: A or P; tt: AM or PM
"short" = h:mm tt; "medium" = h:mm:ss tt

lsTimeFormat(time [, mask, locale]) → returns string

Member Function Syntax

time.lsTimeFormat([mask])

Argument Reference

time date
Required

mask string
Default: short

Values:
  • short
  • medium
  • long

locale string

Geographic/language locale value, where the format is a combination of an ISO 639-1 code and an optional ISO 3166-1 code separated by a dash or an underscore.
Values:
  • en
  • de_DE
  • de_CH
  • ...

Compatibility

ColdFusion:

Member function is available in CF2016+.

Lucee:

Member function is not available.

Examples
Sample code invoking the lsTimeFormat function

lsTimeFormat returns a time value using the locale convention.

<!--- loop through a list of locales and show time values ---> 
 <cfloop LIST = "#Server.Coldfusion.SupportedLocales#" 
 index = "locale" delimiters = ","> 
 <cfset oldlocale = setLocale(locale)> 
  <cfoutput><p><B><I>#locale#</I></B> 
 #lsTimeFormat(now())# 
 #lsTimeFormat(now(), 'hh:mm:ss')# 
 #lsTimeFormat(now(), 'hh:mm:sst')# 
 #lsTimeFormat(now(), 'hh:mm:sstt')# 
 #lsTimeFormat(now(), 'HH:mm:ss')# 
 <hr noshade> 
 </cfoutput> 
 </cfloop> 

lsTimeFormat returns a time value using the specified locale.

writeDump(lsTimeFormat(now(), 'short', 'en_US'));

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub