php时区设置错误

时间:2018-05-12 11:54:14

标签: php datetime timezone

我一直在尝试修复此错误几天..

https://e-scapeps.com/vote/index.php

  

警告:main():依赖系统的时区设置是不安全的。您必需使用date.timezone设置或date_default_timezone_set()函数。如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符。我们现在选择了时区'UTC',但请设置date.timezone以选择您的时区。在第43行的/home/escapeps/public_html/vote/templates/steps/step2.php

     

注意:未定义的变量:第43行的/home/escapeps/public_html/vote/templates/steps/step2.php中的时间

     

警告:main():依赖系统的时区设置是不安全的。您必需使用date.timezone设置或date_default_timezone_set()函数。如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符。我们现在选择了时区'UTC',但请设置date.timezone以选择您的时区。在第43行的/home/escapeps/public_html/vote/templates/steps/step2.php

     

致命错误:函数名称必须是第43行/home/escapeps/public_html/vote/templates/steps/step2.php中的字符串

这里是step2.php的第43行

43: $time = time(true) - date.timezone($vote['callback_date']);

提前致谢,这里的任何帮助都会很棒。

万一你需要这个:这是整个step2.php

<?php
if ($_SERVER['REQUEST_METHOD'] != "POST"
        || !isset($_POST['url'])
        || $_POST['url'] != $_SERVER['HTTP_REFERER']) {
    exit;
}

include '../../constants.php';
include '../../classes/class.database.php';

$db = new Database(db_host, db_user, db_pass, db_data);

if (!$db->connect())
    exit;

if (!isset($_COOKIE['vote_user'])) {
    exit;
}

$username = filter_var($_COOKIE["vote_user"], FILTER_SANITIZE_STRING);
$username = preg_replace("/[^A-Za-z0-9_]/", '_', $username);

$sites = $db->getSites();

if ($sites == null) {
    echo '<div class="alert alert-danger">There are no sites to vote on!</div>';
    exit;
}

foreach ($sites as $site) {
    if ($site['active'] == false) {
        continue;
    }

    $url = str_replace("{sid}", $site['site_id'], $site['url']);
    $url = str_replace("{incentive}", str_replace(" ", "_", $username), $url);

    $vote = $db->getVote($site['id'], $username, $_SERVER['REMOTE_ADDR']);

    if ($vote == null) {
        echo '<a class="btn btn-default site" target="_blank" href="vote.php?site='.$site['id'].'">'.$site['title'].'</a>';
    } else {
            if (!$db->connect())
    exit;

$votm = $db->getVotm();
$votes = $db->getVotes();

if( ! ini_get('date.timezone') )
{
    date_default_timezone_set('GMT');


}
$time = time(true) - date.timezone($vote['callback_date']);
        $timeDiff = 43200 - $time;

        echo '<a class="btn btn-success site" target="_blank" href="#"><i class="fa fa-check"></i> '.formatSeconds($timeDiff).'</a>';
    }
}
?>

<hr style="border-color:transparent;">
Voting as <strong><?php echo str_replace("_", " ", $username); ?></strong>

0 个答案:

没有答案