Newer Version Available
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})