Using date-fns, how it could be converted below piece of code using date-fns. Basically, inputs are like, '01:40:20 PM' or '1:4:2 PM' or '3:2 PM' OR '03:2 PM' And expected output to be consistent like, '03:02:00 PM' , in hh:mm:ss A format.
I could not find any particular method that allows format with time only.
Using moment js, it works fine as below:
if (moment(timeString, ['h:m:s A', 'h:m A'], true).isValid()) {
return moment(timeString, 'hh:mm:ss A').format('hh:mm:ss A');
}