在React中获取在线当前时间



如果我运行此命令并每秒从服务器获取当前时间,缺点是什么?

fetchCurrentTime() {
fetch(this.getApiUrl())
.then(resp => resp.json())
.then(resp => {
const currentTime = resp.dateString;
this.setState({currentTime})
})
} 

您可以使用此API获取当前在线时间https://timezonedb.com/api

new Date().getTime();

最新更新