Who knows how you can flip a date backwards without using tags and the like?
-
If I get the property into a function let's say function (date)
how can I turn it over
from this format 2020-02-18 to this - & gt; 02/18/2020
iterate over it with an array, and then replace?JavaScript Anonymous, Oct 21, 2020 -
new Date('2020-02-18').toLocaleDateString() // 18.02.2020
Well, if you don't want to depend on the user's locale, then
const [year, month, day] = '2020-02-18'.split('-')
alert(`${day}.${month}.${year}`)Anonymous -
Maybe so
Jace Lowe -
let str = '2020-02-18';
console.log(str.replace(/^(\d+)-(\d+)-(\d+)$/, `$3.$2.$1`))Zachary Russo
3 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!