Javascript 根据日期重定向到其他网页

Javascript 根据日期重定向到其他网页,javascript,php,html,redirect,Javascript,Php,Html,Redirect,我更愿意使用Javascript实现这一点,但任何语言都可以 我正在重新设计我的网页。它将于7月31日12:00发布。我已经把这两个版本的网站到不同的目录。我希望主页上的代码根据日期将用户重定向到正确的页面 示例:用户在6月29日下午5:00登录-->重定向到/当前。用户在8月1日下午1:00登录-->重定向到/new。 if (time() < strtotime("06/29/2014 5:00PM")) { //redirect to current header

我更愿意使用Javascript实现这一点,但任何语言都可以

我正在重新设计我的网页。它将于7月31日12:00发布。我已经把这两个版本的网站到不同的目录。我希望主页上的代码根据日期将用户重定向到正确的页面

示例:用户在6月29日下午5:00登录-->重定向到/当前。用户在8月1日下午1:00登录-->重定向到/new。

if (time() < strtotime("06/29/2014 5:00PM"))
{
    //redirect to current
    header("Location : http://website.com/current");
    exit;
}
    elseif(time() > strtotime("01/08/2014 1:00PM")){

    //redirect to new
    header("Location : http://website.com/new");
    exit;
}
if(time()strottime(2014年8月1日下午1:00){
//重定向到新的
标题(“位置:http://website.com/new");
出口
}

使用以下javascript您可以做到这一点

// 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";
}
//今天的日期;
Date.prototype.today=函数(){
return((this.getDate()<10)?“0”:“”)+this.getDate()+“/”+((this.getMonth()+1)<10)?“0”:“”)+(this.getMonth()+1)+“/”+this.getFullYear();
}
如果((新日期()今天())>=“2014年8月1日”)
{
location.href=“新位置url”;
}
其他的
{
location.href=“当前位置url”;
}

对不起,我不太懂javascript,这需要jQuery库吗?不,这是纯javascript。你不需要javascript解决方案。您将受到基于最终用户时区的不同行为的影响。更不用说您也依赖于客户端行为。您想要PHP还是Javascript解决方案?你把你的问题都标记了。为什么要弄乱URI结构之类的东西呢。您最好拥有多个虚拟主机,并在适当的时间进行DNS切换或web服务器配置更改。未捕获引用错误:未定义时间