Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

When counting down to same day, targetFormatMask is one day off #197

Open
Alwyn-RM opened this issue Aug 10, 2021 · 0 comments
Open

When counting down to same day, targetFormatMask is one day off #197

Alwyn-RM opened this issue Aug 10, 2021 · 0 comments

Comments

@Alwyn-RM
Copy link

Alwyn-RM commented Aug 10, 2021

I have 2 moments. One moment I add x seconds. When using the targetFormatMask to show the number of remaining days it always shows 1.
OnTick shows correct number of seconds left and onCountdownEnd is called when time is over.

I'm using this format "DD [days] - HH:mm:ss" but it's the same with "DD:HH:mm:ss"

const dateInFuture = moment().add(60, "seconds");

<ReactMomentCountDown
	toDate={dateInFuture}
	targetFormatMask="DD [days] - HH:mm:ss"
	onTick={onTick}
	onCountdownEnd={onCountdownEnd}
/>

Shows 01 DAYS - 00:00:59 counting down to 01 DAYS - 00:00:00

Probably because you convert to UTC time which is 1st of january 1970 so D will always show 1. Subsquentially 25hrs in the future will say it's 2 days and 1 hour because it converts to 1/2/1970

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant