Search
 
SCRIPT & CODE EXAMPLE
 

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 
Comment

PREVIOUS NEXT
Code Example
Javascript :: iterate object in react 
Javascript :: jquery replace html 
Javascript :: regex repeat n times 
Javascript :: jquery remove multiple classes 
Javascript :: how to iterate over keys in object javascript 
Javascript :: js generate random numbers 
Javascript :: javascript detect page 
Javascript :: first letter of each word in a sentence to uppercase javascript 
Javascript :: converting javascript object to json 
Javascript :: how to call a function with arguments on event listener javascript 
Javascript :: join array of object name javascript 
Javascript :: box shadow in react native 
Javascript :: javascript number format indonesia 
Javascript :: react background image opacity 
Javascript :: chosen-select disable 
Javascript :: js order string 
Javascript :: javascript loop over dictionary 
Javascript :: node exporter service 
Javascript :: React CKEditor Custom build 
Javascript :: await in angular 8 
Javascript :: array from set javascript 
Javascript :: regex match exact string 
Javascript :: convert date format from yyyy-mm-dd to dd-mm-yyyy using value javascript 
Javascript :: javascript simulate click on element 
Javascript :: get element by id in jquery 
Javascript :: add click event listener javascript 
Javascript :: react fetch custom hook 
Javascript :: toggle state react 
Javascript :: scroll to div js 
Javascript :: onclick toggle class react 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =