日复一日更改js HTML

问题描述

我有一个代码

var dayNames = new Array("wednesday","wednesday","thursday","friday","friday");
var Now = new Date();
document.write("Buy Nowe,you geti it on " + dayNames[Now.getDay()]);
<a id="orderBy"></a>

我想在下午2点以后更改一天。有人可以帮我吗?

解决方法

像这样-我假设星期五之后的14:00和星期三14:00之前的任何一天表示星期三交货

const dayNames = ["wednesday","wednesday","thursday","friday","friday"];
let now = new Date();
if (now.getHours() >= 14) now.setDate(now.getDate()+1)
document.write("Buy nowe,you geti it on " + dayNames[now.getDay()]);
<a id="orderBy"></a>

,

您可以将时间设置为从现在开始的14小时。因此,如果是下午2点或之后,则将在第二天及之后的12:00 am进行。

let shippingTime = new Date();
shippingTime.setHours(shippingTime.getHours() + 14);

document.write("Buy now,you get it on " + dayNames[shippingTime.getDay()]);

<a id="orderBy"></a>
,

尝试一下

No matching bindings found for serviceIdentifier: MyController

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...