Newer Version Available
Localization
Component source
1<aura:component>
2 <ui:outputDateTime value="2013-10-07T00:17:08.997Z" timezone="Europe/Berlin" langLocale="de"/>
3</aura:component>The component renders as Okt. 7, 2015 2:17:08 AM.
Additionally, you can use the global value provider, $Locale, to obtain the locale information. The locale settings in your organization overrides the browser’s locale information.
Working with Locale Information
In a single currency organization, Salesforce administrators set the currency locale, default language, default locale, and default time zone for their organizations. Users can set their individual language, locale, and time zone on their personal settings pages.
For example, setting the time zone on the Language & Time Zone page to (GMT+02:00) returns 28.09.2015 09:00:00 when you run the following code.
1<ui:outputDateTime value="09/28/2015" />Running $A.get("$Locale.timezone") returns the time zone name, for example, Europe/Paris. For more information, see "Supported Time Zones" in the Salesforce Help.
1<ui:outputCurrency value="100000" />Similarly, running $A.get("$Locale.currency") returns "¥" when your org’s currency locale is set to Japanese (Japan) - JPY. For more information, see "Supported Currencies" in the Salesforce Help.
Using the Localization Service
The framework’s localization service enables you to manage the localization of date, time, numbers, and currencies. These methods are available in the AuraLocalizationService JavaScript API.
1var dateFormat = $A.get("$Locale.dateFormat");
2var dateString = $A.localizationService.formatDateTime(new Date(), dateFormat);1var dateFormat = "MMMM d, yyyy h:mm a";
2var userLocaleLang = $A.get("$Locale.langLocale");
3return $A.localizationService.formatDate(date, dateFormat, userLocaleLang);1var startDateTime = new Date();
2//return the date time at end of the day
3var endDateTime = $A.localizationService.endOf(d, 'day');
4if( $A.localizationService.isAfter(startDateTime,endDateTime)) {
5 //throw an error if startDateTime is after endDateTime
6}