From 27f90c220c238dc307ea773c455ba0048c2def6b Mon Sep 17 00:00:00 2001 From: thecodrr Date: Wed, 1 Apr 2020 23:11:32 +0500 Subject: [PATCH] feat: allow to show seconds in timeConverter --- apps/web/src/utils/time.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/src/utils/time.js b/apps/web/src/utils/time.js index e3a496252..934c1a04f 100644 --- a/apps/web/src/utils/time.js +++ b/apps/web/src/utils/time.js @@ -23,7 +23,7 @@ const months = [ "Dec" ]; -export function timeConverter(timestamp) { +export function timeConverter(timestamp, showSeconds = false) { if (!timestamp) return; var d = new Date(timestamp), // Convert the passed timestamp to milliseconds yyyy = d.getFullYear(), @@ -32,6 +32,7 @@ export function timeConverter(timestamp) { hh = d.getHours(), h = hh, min = ("0" + d.getMinutes()).slice(-2), // Add leading 0. + sec = ("0" + d.getSeconds()).slice(-2), ampm = "AM", time; @@ -58,6 +59,7 @@ export function timeConverter(timestamp) { h + ":" + min + + (showSeconds ? `:${sec}` : "") + " " + ampm;