Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

UTCToWallTime()

Converts a datetime from UTC to a specified timezone.

Signature

UTCToWallTime (Date date, String timezone, function callback)

Parameters

date
Type: Date
A JavaScript Date object.
timezone
Type: String
A time zone ID based on the class, for example, "America/Los_Angeles".
callback
Type: function
A function to call after the conversion is done. Access the converted value in the first parameter of the callback.

Sample Code

1var format = $A.get("$Locale.timeFormat");
2format = format.replace(":ss", "");
3var langLocale = $A.get("$Locale.langLocale");
4var timezone = $A.get("$Locale.timezone");
5var date = new Date();
6$A.localizationService.UTCToWallTime(date, timezone, function(walltime) {
7    // Returns the local time without the seconds, for example, 9:00 PM
8    displayValue = $A.localizationService.formatDateTimeUTC(walltime, format, langLocale);
9})