Answer the question
In order to leave comments, you need to log in
How to write the site.ru line in php 7 so that "//" are not perceived as comments?
How to write a line in php 7 http://site.ru
so that "//" are not perceived as comments?
Answer the question
In order to leave comments, you need to log in
Do not thank
const monthToInt = val => {
val = val.toLowerCase();
switch (true) {
case !!val.match(/^янв/): return 0;
// TODO добавить больше кейсов
}
}
const dateFromLocaleString = date =>
new Date(
...date
.split(" ")
.reduce(
(acc, val) =>
(acc = [val.match(/\D/) ? monthToInt(val) : parseInt(val), ...acc]),
[]
)
)
dateFromLocaleString('07 янв 2019')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question