0

I am not getting expected output in time value. I am passing value as 20190619131800Z through query parameter and trying to format it according to Salesforce User Timezone. I am using lightning:inputField in lightning component to display this DateTime value. Need urgent help around this.

component.find("verificationDate").set("v.value", $A.localizationService.formatDateTime(component.get("v.SF_VerificationDate"),'YYYY-MM-DDThh:mm:ss-hh:mm'));

Expected Output- 19.06.2019 13.18; Actual Output- 19.06.2019 04.00

1

In your Lightning Page, go to your Javascript Console. and paste the following snippet

eval("$A.localizationService.formatDateTime('20190619131800Z ','YYYY-MM-DDThh:mm:ss-hh:mm');");

It will give output as "Invalid Date"

Now coming to the documentation.

The date parameter can be a String, Number, or most typically a JavaScript Date. If you provide a String value, use ISO 8601 format to avoid parsing warnings.

20190619131800Z is not in ISO 8601 format.

You have to convert 20190619131800Z into 2019-06-19T13:18:00Z for localization service to work. You can do that using string manipulation

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.