I
I
Ilya Beloborodov2015-10-22 14:46:17
JavaScript
Ilya Beloborodov, 2015-10-22 14:46:17

How to parse a date string?

there is a string 2015-10-21 09:35:18 . How to extract hours and minutes from it? Whatever it was 09:35

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2015-10-22
@kowap

s = '2015-10-21 09:35:18';
d = new Date(s);
console.log(d.getHours(), d.getMinutes());

time = '2015-10-21 09:35:18'.split(' ')[1];
parts = time.split(':');
console.log(parts[0], parts[1]);

Choose according to your taste.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question