Spec-Zone.ru › ColdFusion

timeFormat

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

Member Function Syntax

time.timeFormat([mask])

  • CF
  • Lucee
  • BL 1.0.0+
  • See Also: lsTimeFormat dateFormat

    Argument Reference

    time date
    Required

    A date/time value or string to convert

    mask string
    Default: hh:mm tt

    Masking characters that determine the format. h,hh: Hours in 12 hour format,H,HH: Hours in 24 hour format m,mm: Minutess,ss: Seconds l: 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
    Values:
    • short
    • medium
    • long
    • full

    Compatibility

    ColdFusion:

    Member function is available in CF11+. The z Z and X masks were added in CF2016+

    Lucee:

    Member function is available in Lucee5+.

    Examples
    Sample code invoking the timeFormat function

    Format a 12 hour time with am/pm

    timeFormat( createDateTime(2017, 8, 31, 15, 25, 11), "h:mm tt")

    Expected Result: 3:25 PM

    Member Function Example

    Requires CF 11+ or Lucee 5+

    createDateTime(2017, 8, 31, 15, 25, 11).timeFormat("h:mm tt")

    Expected Result: 3:25 PM

    Omitting the Mask

    Should default mask to hh:mm tt

    timeFormat( createDateTime(2017, 8, 31, 15, 25, 11) )

    Expected Result: 03:25 PM

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/timeformat

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API