TimeMillis FormatDateText() - Custom Format Method

Formats a date into a human-readable string using a custom date format.

Function Signature

 string FormatDateText( string format )

string FormatDateText( string format, TimeZone tz, Locale loc )

Parameters

Parameter Type Description

format

string

A string with symbols and literals. See notes below.

tz

TimeZone

The time zone used to convert the point in time represented by the TimeT to text. If not provided, the current user's timezone is used.

loc

Locale

Locale used during formatting. Especially important if dateformat is set to DateFormatConstants.FROM_LOCALE. Indicates language to use for keywords such as "AM", "PM", month names, day of week names, etc.

Return

Type Description

string

The date in human-readable text format.

Technical Details

SBM ModScript version: 11.4.

Example

var t = TimeMillis(1545721199999ll);
Ext.WriteStream( t.FormatDateText( "EEEE, MMMM d, yyyy h:mm:ss:SSS a z" ) );  

Result:

Monday, December 24, 2018 11:59:59:999 PM MST

Notes

Format value is a string with symbols and literals (literals can be escaped inside single tick ( ' ) values if necessary). Symbols are described in ICU documentation. When formatting, the number of times a symbol occurs determines the length of values during output. For instance, "M" will output January as "1", but "MM" will output January as "01". When parsing, it is often best to provide the simplest option "M", which will work with both "1" and "01". TimeMillis is measured in milliseconds and can therefore parse and format millisecond values meaningfully.

Related Topics

TimeMillis