From 917aa5fcb642789fc2b62bd2c60520a44416abac Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 16 Dec 2017 14:32:16 +0200 Subject: [PATCH] Tag and build --- README.md | 15 +++++++++++++++ tag_database | 1 + 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index c15a1a0cb..64dc81117 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ * [Is number](#is-number) * [Is string](#is-string) * [Is symbol](#is-symbol) +* [JSON to date](#json-to-date) * [Measure time taken by function](#measure-time-taken-by-function) * [Number to array of digits](#number-to-array-of-digits) * [Ordinal suffix of number](#ordinal-suffix-of-number) @@ -1311,6 +1312,20 @@ const isSymbol = val => typeof val === 'symbol'; [⬆ back to top](#table-of-contents) +### JSON to date + +Use `Date()`, to convert dates in JSON format to readable format (`dd/mm/yyyy`). + +```js +const jsonToDate = arr => { + const dt = new Date(parseInt(arr.toString().substr(6))); + return `${ dt.getDate() }/${ dt.getMonth() + 1 }/${ dt.getFullYear() }` +}; +// jsonToDate(/Date(1489525200000)/) -> "14/3/2017" +``` + +[⬆ back to top](#table-of-contents) + ### Measure time taken by function Use `console.time()` and `console.timeEnd()` to measure the difference between the start and end times to determine how long the callback took to execute. diff --git a/tag_database b/tag_database index 9f1b18f46..05dc761bd 100644 --- a/tag_database +++ b/tag_database @@ -55,6 +55,7 @@ is-function:utility is-number:utility is-string:utility is-symbol:utility +JSON-to-date:utility last-of-list:array measure-time-taken-by-function:utility median-of-array-of-numbers:array