function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manish.SinghManish.Singh 

Set Datetime format of Lightning:input datetime

Hello everyone,
Can anyone tell me, How I exactly show the date-time selected in the lightning input datetime field as a formatted string?
User-added image
My Output:
User-added image
Code that i used to format
$A.localizationService.formatDate(string datetime,"MMM dd yyyy, hh:mm:ss a");
I want to show exactly the selected date/time as a formatted string in the output.
Thanks
PriyaPriya (Salesforce Developers) 

Hi Manish,

Kindly refer this link :- 

https://developer.salesforce.com/docs/component-library/bundle/lightning:formattedDateTime/example

If it helps you, please mark it as best answer.

Regads,

Priya Ranjan

Manish.SinghManish.Singh
Thanks for replying priya, but I want to show lighning:datetime input value as formated string in controller js
Suraj Tripathi 47Suraj Tripathi 47
Hi Manish,
Greetings!

You can use lightning:formattedDateTime tag in the Aura component to display date time in different formats.
for refer-> https://developer.salesforce.com/docs/component-library/bundle/lightning:formattedDateTime/example#lightningcomponentdemo:exampleDateTimeFormatting

If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi