如何在React中显示倒数计时器
我正在使用Moment.js。 如果事件延迟,我想显示一个计数计时器。 我正在从BE那里获得事件,但我不确定如何在当前时间上显示计时器。
到目前为止,我已经尝试过这样的尝试,
const currentDateAndTime = moment().format('YYYY-MM-DD HH:mm');
const eventStartDateAndTime = moment.tz(moment(eventStartDate).format('YYYY-MM-DD HH:mm'), timeZone).local();
我想在这里显示倒数计时器 https://prnt.sc/kxqbjqbjqofab6m 您能帮我逻辑吗?
I am using moment.js.
I want to show a count down timer if an event is delayed.
I am getting the eventStartDate from the BE but I am not sure how to show timer with respect to current time.
So far I have tried like this
const currentDateAndTime = moment().format('YYYY-MM-DD HH:mm');
const eventStartDateAndTime = moment.tz(moment(eventStartDate).format('YYYY-MM-DD HH:mm'), timeZone).local();
I want to show the countdown timer here
https://prnt.sc/kXqBjQOFab6m
Can you please help me with the logic?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为,您会从中得到这个想法。阅读有关“使用效应”和清理的信息。
I think, you will get the idea from this. Read about 'useEffect' and cleanup.