日复一日地改变 js html
Change day after hour js html
我有一个代码:
var dayNames = new Array("wednesday", "wednesday", "thursday", "friday",
"wednesday", "thursday", "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", "wednesday", "thursday", "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>
试试这个
var now = new Date();
var day = now.getDay();
if (now.getHours() >= 14){
day += 1;
}
document.write("Buy nowe, you geti it on " + dayNames[day]);
您可以将时间设置为从现在起 14 小时。因此,如果是下午 2 点或之后,将被视为 12:00am 第二天及之后。
let shippingTime = new Date();
shippingTime.setHours(shippingTime.getHours() + 14);
document.write("Buy now, you get it on " + dayNames[shippingTime.getDay()]);
<a id="orderBy"></a>
我有一个代码:
var dayNames = new Array("wednesday", "wednesday", "thursday", "friday",
"wednesday", "thursday", "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", "wednesday", "thursday", "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>
试试这个
var now = new Date();
var day = now.getDay();
if (now.getHours() >= 14){
day += 1;
}
document.write("Buy nowe, you geti it on " + dayNames[day]);
您可以将时间设置为从现在起 14 小时。因此,如果是下午 2 点或之后,将被视为 12:00am 第二天及之后。
let shippingTime = new Date();
shippingTime.setHours(shippingTime.getHours() + 14);
document.write("Buy now, you get it on " + dayNames[shippingTime.getDay()]);
<a id="orderBy"></a>