From 2427df8aa11a786249d40a2db35503dfe5b40bc5 Mon Sep 17 00:00:00 2001 From: Ramiro Vazquez Date: Tue, 21 Apr 2020 15:48:42 -0300 Subject: [PATCH] convert a milliseconds timestamp into seconds --- src/utils/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/index.tsx b/src/utils/index.tsx index 6ad327e..710527d 100644 --- a/src/utils/index.tsx +++ b/src/utils/index.tsx @@ -54,9 +54,13 @@ export const toNiceDate = timestamp => { export const getModalContainer = Content => +function msToSeconds(time) { + return time >= 1e12 ? (time / 1e3).toFixed(0) : time +} + export const timeLeft = (end): string => { const today = new Date() - const end_date = fromUnixTime(end) + const end_date = fromUnixTime(msToSeconds(end)) if (differenceInSeconds(end_date, today) <= 0) return 'Ended' const minsDiff = differenceInMinutes(end_date, today)