Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert to 24 hours format javasript

// 12:05:23AM > 00:05:23,  11:05:23AM > 23:05:23
function timeConversion(s) {
    const pad = (num)=>num.toString().padStart(2,0)
   const [hour, minutes, seconds] = s.split(':').map(parseFloat)
    return s.includes('AM')
        ? `${pad(hour % 12)}:${pad(minutes)}:${pad(seconds)}`
        : `${pad((hour  % 12) + 12 )}:${pad(minutes)}:${pad(seconds)}`;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #hours #format #javasript
ADD COMMENT
Topic
Name
2+5 =