Output Date Time (Deprecated)

ui:outputDateTime

Deprecated as of API version 47.0. We recommend migrating to Lightning Web Components and using the lightning-formatted-date-time or lightning-formatted-time component.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App

Deprecation Guidelines 

We recommend using Lightning Web Components whenever possible. When migrating to Lightning Web Components, use lightning-formatted-date-time or lightning-formatted-time.

For more information, see Aura Components in the ui Namespace Are Deprecated.

Usage Overview (Deprecated) 

A ui:outputDateTime component represents a date and time output that is wrapped in an HTML span tag. We recommend using lightning:formattedDateTime instead of ui:outputDateTime.

This component can be used with ui:inputDateTime, which takes in a date input. To apply Lightning Design System styling, we recommend that you use lightning:input with type="datetime-local" instead of ui:inputDateTime.

ui:outputDateTime retrieves the browser’s locale information and displays the date accordingly. To display a date and time, you can use an attribute value and bind it to the ui:outputDateTime component.

1<aura:attribute name="myDateTime" type="Date" default="2014-09-29T00:17:08z" />
2
3<ui:outputDateTime value="{!v.myDateTime}" />

The previous example renders the following HTML.

1<span class="uiOutputDateTime">Sep 29, 2014 12:17:08 AM</span>

To display record data for Salesforce objects, use lightning:outputField with lightning:recordViewForm, or use lightning:recordForm. To display record data with a custom layout, use force:recordData.

Note

Attributes 

NameDescriptionTypeDefaultRequired
bodyThe body of the component. In markup, this is everything in the body of the tag.Aura.Component[]
formatA string (pattern letters are defined in java.text.SimpleDateFormat) used to format the date and time of the value attribute.String
langLocaleDeprecated. The language locale used to format date value. It only allows to use the value which is provided by Locale Value Provider, otherwise, it falls back to the value of $Locale.datetimeLocale. It will be removed in an upcoming release.String
timezoneThe timezone ID, for example, America/Los_Angeles.String{!$Locale.timezone}
valueAn ISO8601-formatted string representing a date time.String