K
K
Kirill Kontorovich2019-04-10 13:34:35
JavaScript
Kirill Kontorovich, 2019-04-10 13:34:35

How to parse a date from a string in JS?

I would like to know, I get the date from php, with a string like "2019-04-10 08:42:14", I would like to parse it into separate parts. Since I'm using VUE on the front. I'm thinking of making 2 filters. The first would give only the day, the second year and month.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stockholm Syndrome, 2019-04-10
@ishimitsu

new Date("2019-04-10 08:42:14");

D
Dmitry Gololobov, 2019-04-10
@dGololobov

As an option, I suggest you use moment.js - one of the easiest ways to work with date and time in js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question