Merge #113
This commit is contained in:
14
README.md
14
README.md
@ -57,6 +57,7 @@
|
||||
* [Scroll to top](#scroll-to-top)
|
||||
|
||||
### Date
|
||||
* [Convert to english date](#convert-to-english-date)
|
||||
* [Get days difference between dates](#get-days-difference-between-dates)
|
||||
* [JSON to date](#json-to-date)
|
||||
|
||||
@ -690,6 +691,19 @@ const scrollToTop = _ => {
|
||||
[⬆ back to top](#table-of-contents)
|
||||
## Date
|
||||
|
||||
### 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'
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
### Get days difference between dates
|
||||
|
||||
Calculate the difference (in days) between to `Date` objects.
|
||||
|
||||
10
snippets/convert-to-english-date.md
Normal file
10
snippets/convert-to-english-date.md
Normal 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'
|
||||
```
|
||||
@ -22,6 +22,7 @@ compact:array
|
||||
compose-functions:function
|
||||
convert-string-from-camelcase:string
|
||||
convert-string-to-camelcase:string
|
||||
convert-to-english-date:date
|
||||
count-occurrences-of-a-value-in-array:array
|
||||
current-URL:browser
|
||||
curry:function
|
||||
|
||||
Reference in New Issue
Block a user