Skip to content

Commit

Permalink
convert a milliseconds timestamp into seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ramirotw committed Apr 21, 2020
1 parent 9675a79 commit 2427df8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ export const toNiceDate = timestamp => {

export const getModalContainer = Content => <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)
Expand Down

0 comments on commit 2427df8

Please sign in to comment.