From a7f4f9af272be03a6f0b1443a17ff22e3659b321 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sun, 6 Sep 2020 14:42:27 +0200 Subject: [PATCH] Utils file. Includes date format function. --- src/utils.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/utils.js diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..7644e4b --- /dev/null +++ b/src/utils.js @@ -0,0 +1,12 @@ + +const dateString = (date) => { + const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(date) + const mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(date) + const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date) + + return `${ye}-${mo}-${da}` +} + +module.exports = { + dateString +}