formatDate
[ Function ]
public static formatDate(
date: Date,
options?: TcHmi.Localization.FormatOptions
): string | null;
Formats a Javascript timestamp in a specific time zone, language, and level of detail as a string. The output also contains milliseconds.
If the user does not specify a time zone or locale, the settings of the current user apply. These are also available under TcHmi.Server.getCurrentUserConfig.
Parameter
Name | Type | Description |
---|---|---|
date | To the formatting date | |
options [optional] | Formatting options |
Return value
Type | Description |
---|---|
Formatted string or null in case of error. |
Available from version 1.10.1336.10 |
Sample - JavaScript
var date = new Date('2019-12-02T14:15:16.017Z');
var result = TcHmi.Localization.formatDate(date);
console.log(result); // For a user with timeFormatLocale 'de-DE' and timeZone set to 'Europe/Berlin': 2.12.2019, 15:15:16,017
var date = new Date('2019-12-02T14:15:16.017Z');
var result = TcHmi.Localization.formatDate(date, {
type: 'time',
timeZone: 'Europe/Helsinki',
locale: 'fr-FR'
});
console.log(result); // '16:15:16,017'
Available from version 1.10.1336.10 |