我是新手,并通过在线查找代码将其拼凑在一起。我需要根据EST的当前日期和时间显示最早的交货日期。截止日期为周日和周一。我有它基于本地机器时区工作,但我需要它只基于EST。美国东部时间截止时间为下午3点,太平洋时间截止时间为下午12点。我希望这是有道理的。这是我到目前为止的代码。
<i class="fa fa-calendar" aria-hidden="true"></i> Choose your delivery date at checkout.
<script src='//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js'></script>
<script type="text/javascript">
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
var seconds = currentTime.getSeconds()
</script>
<h4 class="delivery">Earliest Delivery Date: <span id="eDelivery" class="eDelivery"></span></h4>
<script>
var eDelivery = Date.today().addDays(1);
if(hours >= 15 && eDelivery.is().tuesday()){
eDelivery = Date.today().addDays(2);
}
if(hours >= 15 && eDelivery.is().wednesday()){
eDelivery = Date.today().addDays(2);
}
if(hours >= 15 && eDelivery.is().thursday()){
eDelivery = Date.today().addDays(2);
}
if(hours >= 15 && eDelivery.is().friday()){
eDelivery = Date.today().addDays(2);
}
if(hours >= 15 && eDelivery.is().saturday()){
eDelivery = Date.today().addDays(2);
}
if (eDelivery.is().sunday() || eDelivery.is().monday()) {
eDelivery = eDelivery.next().tuesday();
}
document.getElementById('eDelivery').innerHTML = eDelivery.toString('dddd, MMMM dS');
</script>
&#13;
有人可以帮助我整合EST,并告诉我是否有任何改进可以做到?
非常感谢。