我有这个代码并且运作良好,但给了我2小时的时间
$('.given_date').each(function() {
var $this = $(this);
var utcTime = $this.data('gamestart');
var utcTimes = $this.data('gameends');
var startTime = moment(utcTime, 'YYYY-MM-DD HH:mm');
var endTimes = moment(utcTimes, 'YYYY-MM-DD HH:mm');
var endTime = moment.utc().format("YYYY-MM-DD HH:mm");
var x = startTime.diff(endTime, 'minutes');
var y = endTimes.diff(endTime, 'minutes');
switch (true) {
case (x > 30):
var localTime = moment.utc(utcTime).toDate();
$this.parent().find(".stsrt58").text(moment(localTime).format('LT').replace("PM", "مساء").replace("AM", "صباحا"));
localTime = moment(localTime).format('YYYY-MM-DD HH:mm:ss');
$this.countdowntimer({
dateAndTime : localTime
});
break;
case (x > 0 ):
$this.parent().find(".stsrt58").html('<div class="">workin soon </div>');
var localTime = moment.utc(utcTime).toDate();
localTime = moment(localTime).format('YYYY-MM-DD HH:mm:ss');
$this.countdowntimer({
dateAndTime : localTime
});
break;
case (y > 0 ):
$this.parent().find(".stsrt58").html('<div class="blink_txt fximres1"> working now</div>');
break;
default:
$this.parent().find(".stsrt58").html('<div class="fximres1"> job end</div>');
break;
}
});
我尝试使用.zone(“非洲/开罗”)来获取我的实时时间
$('.given_date').each(function() {
var $this = $(this);
var utcTime = $this.data('gamestart');
var utcTimes = $this.data('gameends');
var startTime = moment(utcTime, 'YYYY-MM-DD HH:mm');
var endTimes = moment(utcTimes, 'YYYY-MM-DD HH:mm');
var endTime = moment.utc().zone("Africa/Cairo").format("YYYY-MM-DD HH:mm");
var x = startTime.diff(endTime, 'minutes');
var y = endTimes.diff(endTime, 'minutes');
switch (true) {
case (x > 30):
var localTime = moment.utc(utcTime).zone("Africa/Cairo").toDate();
$this.parent().find(".stsrt58").text(moment(localTime).zone("Africa/Cairo").format('LT').replace("PM", "مساء").replace("AM", "صباحا"));
localTime = moment(localTime).zone("Africa/Cairo").format('YYYY-MM-DD HH:mm:ss');
$this.countdowntimer({
dateAndTime : localTime
});
break;
case (x > 0 ):
$this.parent().find(".stsrt58").html('<div class=""> working soon</div>');
var localTime = moment.utc(utcTime).zone("Africa/Cairo").toDate();
localTime = moment(localTime).zone("Africa/Cairo").format('YYYY-MM-DD HH:mm:ss');
$this.countdowntimer({
dateAndTime : localTime
});
break;
case (y > 0 ):
$this.parent().find(".stsrt58").html('<div class="blink_txt fximres1"> working now</div>');
break;
default:
$this.parent().find(".stsrt58").html('<div class="fximres1"> job end</div>');
break;
}
});
只有冷却工作良好,但不能在hrml工作时打印状态时间,现在正在工作,并在我的页面中结束工作
代码中的问题是什么