0

I have time field in my object, which I'm using in my lightning:input field to display. The value which I'm getting is in Decimal Time and to pre populate that value in lightning:input time type, I need to convert it into ISO8601 format. Is there any way to convert it in that format, so that it prepopulate in lightning:input

Thanks

2

I presume you mean epoch time (or Unix time), which specifies the number of milliseconds since Jan 1, 1970. JavaScript has an easy method for doing this: the Date constructor, followed by the Date.toISOString method.

var isoTime = new Date(unixTime).toISOString();
3
  • This seems to be working, but the format is in date time also in string – sfdc Apr 10 '20 at 15:33
  • @sfdc You could split the string on T and use the second half to get just the time. – sfdcfox Apr 10 '20 at 15:35
  • Thanks it works – sfdc Apr 10 '20 at 16:16

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.