Skip to content

Commit

Permalink
fix: avoid negative values in countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
codejijo committed Nov 5, 2021
1 parent d0db2c8 commit 0716952
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion component/layout/EventLayouts/EventDate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export default function EventDate({ eventDate }) {
const countDown = useCallback(() => {
setInterval(() => {
const now = new Date();
const dateOfEvent = new Date(eventDate);
const then = moment(eventDate).diff(now);
var d = moment.duration(then);
setCount(d._data);
if(now <= dateOfEvent) setCount(d._data);
}, 1000);
}, [eventDate]);

Expand Down

0 comments on commit 0716952

Please sign in to comment.