Display Formats for Date and Time in Dynamic Server Pages
In dynamic server pages, display formats for date and time may not be applied as expected, depending on the data type of the field, the HTML control to which the field's widget resolves, and the browser used.
A Date, Time, or DateTime field is usually used with an
htmlinput widget that resolves to an HTML input control of type
"text" (such as the EditBox logical widget) or
"date" (such as the Datepicker logical widget). If the HTML date input control is not supported by the browser, it will use a text input control instead.
In either case, when a Date, Time, or DateTime field resolves to an HTML text input control, the data is parsed and converted to a value that can be displayed. If parsing fails, a format error is displayed in the console of the browser.
When parsing succeeds, the following considerations can affect the way the data is formatted:
- Locale-based formatting is applied using the value set by $webinfo("locale"), which sets the DSP client-side locale. For more information, see $webinfo("Locale").
- If $webinfo("locale") has not been set, NLS formats are applied but the locale defaults to
"en". (The NLS locale is ignored, as it only affects server-side processing.) Consequently, only English text is displayed in formats that call for text. For example, if the locale is French,
DIS($NLS(MEDIUM))results in something like
May 23 2019 10:35:45instead of
23 mai 2019 10:35:45.
- When an NLS format has no parameter, data is displayed in the internal format. For example,
DIS($NLS())results in something like
- If incomplete data is entered in a Date, Time, or DateTime field, an attempt is made to complete it. The way it is completed may differ depending on the control, the data type, and the browser.
- If the data entered in a Date, Time, or DateTime field is valid but does not match the display pattern exactly, the display data may fall back to a default value.
- If an incorrect separator is used (such as a hyphen instead of a slash), an attempt is made to convert to the separator character defined by the display format. Depending on the entered separator, this may fail, and the characters they are converted to may differ with the control, data type, and browser.
- Any character (or sequence of characters) that does not match a pattern is assumed to be a separator and is displayed as literal text. Thus,
- Display formats that specify uppercase or lowercase characters for days and months are ignored. Initial characters are always capitalized. Thus,
DIS(AA*, dd-MMM*-yyyy)results in
Thursday, 23-May-2019, not
- When a date is displayed in an EditBox (
text) and the value does not conform with the field's display format, is displayed with asterisks before and after the value, and a format error is displayed in the browser's console. Thus, if the display format is
DIS(dd-MMM-yyyy hh:nn:ss.tt)and the value is
1939-01-16T02:25:59.69, it is displayed as
*1939-01-16T02:25:59.69*. This allows the user to correct the erroneous value so that it cannot be submitted to the server.