I am trying to convert a String that consist of "AM" or "PM" into a 24 hours format. I have tried using formatDate but couldn't able to get the outcome that I would like. The following are examples of the values that I am trying to convert from String into a 24 hours format String.
String (Before) | String (After) |
---|---|
10:00AM | 10:00 |
12:00PM | 12:00 |
02:00PM | 14:00 |
04:00PM | 16:00 |
Is using formatDate a recommended approach in this case or if not what other possible methods or way am I able to convert this String into the format above without complicating the codes?