【问题标题】:Get online current time in React在 React 中获取在线当前时间
【发布时间】:2020-02-23 06:36:56
【问题描述】:

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

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

【问题讨论】:

    标签: javascript reactjs time


    【解决方案1】:

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

    new Date().getTime();

    【讨论】:

      猜你喜欢
      • 2019-05-20
      • 2012-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多