You are viewing a single comment's thread. Return to all comments →
I think one approrach to use Javascript string split.
const [time, period] = time12h.split(/(AM|PM)/); const [hours, minutes, seconds] = time.split(':'); const hours24h = period === 'PM' && hours !== '12' ? parseInt(hours) + 12 : hours === '12' && period === 'AM' ? '00' : hours; return `${hours24h}:${minutes}:${seconds}`;
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
I think one approrach to use Javascript string split.