Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何与当地人一起度过美好的当地时间?_Javascript_React Native - Fatal编程技术网

Javascript 如何与当地人一起度过美好的当地时间?

Javascript 如何与当地人一起度过美好的当地时间?,javascript,react-native,Javascript,React Native,我在倒计时,他在工作。我唯一找不到的就是如何把握好当地时间?我想我需要改变一下日期。现在()但我不确定 TimerDecibels = () => { return this.state.sport.clubs.map((element) => { // Set the date we're counting down to // Update the count down every 1 second setInterval(() =

我在倒计时,他在工作。我唯一找不到的就是如何把握好当地时间?我想我需要改变一下日期。现在()但我不确定

TimerDecibels = () => {
    return this.state.sport.clubs.map((element) => {
      // Set the date we're counting down to

      // Update the count down every 1 second

      setInterval(() => {
        // Get today's date and time
        var now = Date.now();
        var countDownDate = new Date(element.dateMatchStop).getTime();

        // Find the distance between now and the count down date
        var distance = countDownDate - now;

        // Time calculations for days, hours, minutes and seconds

        var hours = Math.floor(
          (distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60),
        );
        var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
        var seconds = Math.floor((distance % (1000 * 60)) / 1000);

        // Output the result in an element with id="demo"

        this.setState({heures: hours});
        this.setState({minutes: minutes});
        this.setState({secondes: seconds});

        // If the count down is over, write some text
        if (distance < 0) {
          return this.setState({expired: 'EXPIRED'});
        }
      }, 0);
    });
  };
TimerDecibels=()=>{
返回此.state.sport.clubs.map((元素)=>{
//确定我们倒计时的日期
//每1秒更新一次倒计时
设置间隔(()=>{
//获取今天的日期和时间
var now=Date.now();
var countDownDate=新日期(element.dateMatchStop.getTime();
//找出现在和倒计时日期之间的距离
var距离=倒计时日期-现在;
//天、小时、分钟和秒的时间计算
var小时=数学楼层(
(距离%(1000*60*60*24))/(1000*60*60),
);
var分钟=数学楼层((距离%(1000*60*60))/(1000*60));
var秒=数学楼层((距离%(1000*60))/1000);
//在id=“demo”的元素中输出结果
this.setState({heures:hours});
this.setState({minutes:minutes});
this.setState({secondes:seconds});
//如果倒计时结束,写一些文字
如果(距离<0){
返回此.setState({expired:'expired'});
}
}, 0);
});
};

好的当地时间是什么意思?@derpirscher我们需要“巴黎”时间,但我们还有两个小时的倒计时时间
元素。dateMatchStop
@derpirscher这是数据库上比赛结束的UTC日期我指的是确切的值和类型。它是一个数字(例如一些
getTime()
的结果)还是日期的字符串表示形式,如“2020-09-03T12:34:56”。请注意,除非给出了特定的时区(新的
日期('2020-09-03T12:34:56')
新日期('2020-09-03T12:34:56Z')
的结果在CEST中相差2小时,第一个是本地时间,第二个是UTC)。如果它是一个数字,它是如何生成的?