2

I have used a time field which I want to show in a lightning component

When I fill 8:00 in my field my result is 30600000 in my lightning component. I have searched for a time tag or formatting but could not find any explanation

Below the part of my lightning component

<td data-label="">
     <div class="slds-truncate" title="">
         {!Training.Starttime__c}
     </div>
</td>
4

You can use the Formatted Date Time <lightning:formattedDateTime> or Formatted Time <lightning:formattedTime> component to display a formatted time value.

Your Code using the Formatted Time component would be as below.

 <td data-label="">
       <div class="slds-truncate" title="">
           <lightning:formattedTime value="{!Training.Starttime__c}" />
       </div>
 </td>

You could also use the lightning:outputField if you want to display the field type as is on the Sobject record.

  • Di you know what timezone this uses? – Keith C Jul 20 '18 at 8:38
  • Formatted Time component displays a read-only representation of time in the user's locale format. A valid ISO8601 formatted time string must be used. – Jigar Shah Jul 20 '18 at 8:41
  • @JigarShah I tried all of the above with central europe summertime amsterdam but this doe not outpu anything with 8:00 – Thomas Jul 20 '18 at 8:59
  • Salesforce uses the format HH:mm:ss.SSSZ for time fields. The time field is a timestamp without the date included. Time values in Salesforce are not localized or associated with a time zone. – Jigar Shah Jul 20 '18 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.