The following example shows how you can override the default timezone attribute. The output displays the time in the format hh:mm by default.
<aura:component> <ui:outputDateTime value="2013-10-07T00:17:08.997Z" timezone="Europe/Berlin" /> </aura:component>
The component renders as Oct 7, 2013 2:17:08 AM.
<aura:component> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <aura:attribute name="datetime" type="DateTime"/> <lightning:formattedDateTime value="{!v.datetime}" timeZone="Europe/Berlin" year="numeric" month="short" day="2-digit" hour="2-digit" minute="2-digit" second="2-digit"/> </aura:component>
({ doInit : function(component, event, helper) { var date = new Date(); component.set("v.datetime", date) } })
This example creates a JavaScript Date instance, which is rendered in the format MMM DD, YYYY HH:MM:SS AM.
<lightning:formattedDateTime value="{!v.datetime}" timeZone="Europe/Berlin" year="numeric" month="numeric" day="numeric"/>
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.
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.
<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.
<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.