0

I am trying to create a dynamic help text within lightning component having formatted date time value. But it seems it allow only text.

Current code:

 <lightning:helptext content="{!('Changed at' + case.Custom_DateTime_Field__c)}"  iconName="action:info"/>

Current Output showing datetime in "2020-07-10T15:08:47.000Z" format. Can we change it to "2020-07-10 03:08 PM" ?

Is there any way to use lightning:formattedDateTime with helptext ? Any other alternative ?

0

I would suggest to do formatting at the Apex level and pass the string to the lightning component.

Doc link - Date Time class

Code from doc-

Datetime GMTDate = 
  Datetime.newInstanceGmt(2011,6,1,12,1,5);
String strConvertedDate = 
  GMTDate.format('MM/dd/yyyy HH:mm:ss', 
                 'America/New_York');
// Date is converted to 
// the new time zone and is adjusted
// for daylight saving time.
System.assertEquals(
  '06/01/2011 08:01:05', strConvertedDate);

Also, if you're not using Apex, you can think for JS controller for formatting. IMO, View portion should have only view functionality.

| improve this answer | |

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.