【问题标题】:Redirect based on time of day in London根据伦敦一天中的时间重定向
【发布时间】:2014-06-17 18:38:50
【问题描述】:

如何根据伦敦的时间重定向 URL。我已经看到了使用本地机器时间的 javascript 和使用服务器位置时间的 PHP 的其他方法。使用 PHP 方法,必须在伦敦时间设置服务器才能使其正常工作,但我无权访问它。无论客户在世界的​​哪个地方,有没有办法按照伦敦一天中的时间进行重定向?

【问题讨论】:

标签: javascript php html redirect


【解决方案1】:

试试这样的:

<?php date_default_timezone_set('Europe/London');
$time = date("H");
if($time<12){
  header("Location: siteerly.php");
  exit();
}
else{
  header("Location: siteelse.php");
  exit();
}

您可以随意修改它。请记住在输出任何 html 代码之前放置此代码。

【讨论】:

  • 标题中的位置不是大写的吗?
  • 没关系。 Et 以任何方式重定向。
【解决方案2】:

你可以使用

$_SERVER['REQUEST_TIME'];

它将返回当前的 UNIX 时间戳。

http://ch1.php.net/manual/en/function.time.php

这是来自 php 文档的手册页

【讨论】:

    猜你喜欢
    • 2011-02-02
    • 2014-09-26
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-28
    • 1970-01-01
    • 1970-01-01
    • 2018-07-07
    相关资源
    最近更新 更多