react-sexy-countdown
Install
npm i --save react-sexy-countdown
Import
Support this date&time format only
2018-05-29T07:00:00+07:00
Can use moment-timezone for convert format
const dateFormat = moment.tz(1527552000000, 'Asia/Bangkok').format()
console.log(dateFormat); //2018-05-29T07:00:00+07:00
Config props
Props | Type | Default | Format Example |
---|---|---|---|
date | String | Date.now() | 2018-05-29T07:00:00+07:00 |
onEndCountdown | Func | null | (count) => console.log(count) |
lang | String | en | "th" or "en" |
displayText | Object | {} | { Days: 'Days', Day: 'Day', Hours: 'Hours', Min: 'Min', Sec: 'Sec' } |
lastTextTime | Object | {} | set text after number countdown example: { Day: 'D', Hours: 'H', Min: 'M', Sec: 'S' } |
beforeTextTime | Object | {} | set text before number countdown example: { Day: 'D', Hours: 'H', Min: 'M', Sec: 'S' } |
isDayDoubleZero | Boolean | true | "00 : 00 : 00 : 00" if true "0 : 00 : 00 : 00" |
isHoursDoubleZero | Boolean | true | "00 : 00 : 00 : 00" if true "00 : 0 : 00 : 00" |
isMinDoubleZero | Boolean | true | "00 : 00 : 00 : 00" if true "00 : 00 : 0 : 00" |
isSecDoubleZero | Boolean | true | "00 : 00 : 00 : 00" if true "00 : 00 : 00 : 0" |
using
<Countdown date="2018-05-29T07:00:00+07:00" onEndCountdown= console lang="th" displayText= Days: 'วัน' Day: 'วัน' Hours: 'ชั่วโมง' Min: 'นาที' Sec: 'วินาที' lastTextTime= Day: 'D' isDayDoubleZero= true />
Style (with className for you custom style)
Day is 12 D Houts is 12 H Min is 12 M Sec is 12 S