Skip to main content

Countdown

Template for action cards containing a countdown

Usage#

// Countdown for 1 hour in the future (3600 seconds)<ActionCardCountdownTemplate countdownProps={{until: 3600}} onPress={() => console.log("Pressed 'Next' button")}/>

Specific Date#

Use the getSecondsUntil function to easily get the seconds until a desired date.

caution

Month is 0-index e.g. January is 0 not 1. December is 11 not 12.

// Specific day of the year (Midnight)<ActionCardCountdownTemplate countdownProps={{until: new Date(YEAR, MONTH, DAY)}} onPress={() => console.log("Pressed 'Next' button")}/>
// Specific hour of the day<ActionCardCountdownTemplate countdownProps={{until: new Date(YEAR, MONTH, DAY, HOUR)}}  onPress={() => console.log("Pressed 'Next' button")}/>
// Specific minute of the hour<ActionCardCountdownTemplate countdownProps={{until: new Date(YEAR, MONTH, DAY, HOUR, MINUTE)}}  onPress={() => console.log("Pressed 'Next' button")}/>
// Specific time of the day<ActionCardCountdownTemplate countdownProps={{until: new Date(YEAR, MONTH, DAY, HOUR, MINUTE, SECOND)}}  onPress={() => console.log("Pressed 'Next' button")}/>

Epoch time#

Using epoch instead of an actual date.

<ActionCardCountdownTemplate countdownProps={{until: new Date(epoch * 1000)}} onPress={() => console.log("Pressed 'Next' button")}/>
note

Epoch timestamp is the epoch time in milliseconds instead of seconds.

Paused countdown#

Pass the `paused: true value to the countdownProps

// Countdown for 1 hour in the future (3600 seconds)<ActionCardCountdownTemplate countdownProps={{until: 3600, paused: true}} onPress={() => console.log("Pressed 'Next' button")}/>

Props#

NameTypeDefaultDescription
countdownPropsActionCardCountdownPropsundefinedProps passed to the bullet list. See props here
onPressfunction () => anyundefinedCallback that is called when pressing the 'next' button.

*required