This commit is contained in:
Angelos Chalaris
2017-12-17 12:48:07 +02:00
parent c5e63542e6
commit 622b4286c6
3 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,10 @@
### Convert to English date
Use `Date.toISOString()`, `split('T')` and `replace()` to convert a date from American format to English format.
Throws an error if the passed time cannot be converted to a date.
```js
const toEnglishDate = (time) =>
{try{return new Date(time).toISOString().split('T')[0].replace(/-/g, '/')}catch(e){return}};
// toEnglishDate('09/21/2010') -> '21/09/2010'
```