Converting time from 12-hour AM/PM format to 24-hour format without AM/PM – JavaScript

By using toLocaleTimeString() :

Explanation : 

1. time = "11:40:22 PM"
2. date = 2022-01-01T23:40:22.000Z (we can give any date as we are converting only time)
3. formattedTime = 23:40:22 ("en-GB" means 24-hour time without AM/PM)

Leave a comment