Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert string in hh:mm am/pm to date js

var input   = '10:23 PM',
    matches = input.toLowerCase().match(/(d{1,2}):(d{2}) ([ap]m)/),
    output  = (parseInt(matches[1]) + (matches[3] == 'pm' ? 12 : 0)) + ':' + matches[2] + ':00';

console.log(output); // 22:23:00 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #string #date #js
ADD COMMENT
Topic
Name
9+5 =