gpt4 book ai didi

javascript - 在列出的日期或时间使用 PHP 或 Javascript 更改网页

转载 作者:行者123 更新时间:2023-11-27 23:50:46 24 4
gpt4 key购买 nike

我是 PHP 新手,我想知道这样的事情是否可行。基本上在我的网络服务器上我有多个索引文件。前任。 Christmas.html、normal.html、Halloween.html。有没有办法制作一个 index.php 文件,将您重定向到特定日期的特定页面?因此,如果是圣诞节,PHP 页面会将您重定向到 Christmas.html 页面。谢谢!

我已经尝试过了

// For todays date;
Date.prototype.today = function () {
return ((this.getDate() < 10)?"0":"") + this.getDate() +"/"+ (((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ this.getFullYear();
}

if((new Date().today()) >= "01/08/2014")
{
location.href ="new location url";
}
else
{
location.href="current location url";
}

但我不想每年都更改日期才能再次正常工作。有办法解决这个问题吗?

最佳答案

当然,您可以使用header function例如,在 PHP 中设置新位置。

$month = (int)date('n');
$day = (int)date('j');

if ($month == 12 && $day >= 24 && $day <= 26) {
header('Location: Christmas.html');
}

关于javascript - 在列出的日期或时间使用 PHP 或 Javascript 更改网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32723909/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com