我在我的 PHP 页面上不断收到此错误。我认为错误是因为我的服务器上安装的 php 版本但是当我检查它时
<?php
echo "Version is: " . phpversion();
?>
PHP 版本是 5.2.17。
我当前的代码是:
<form method="post" action="">
<select name="timezone2" id="timezone2" class="timezone2">
<option value="Pacific/Midway">(GMT-11:00) Midway Island, Samoa</option>
<option value="America/Adak">(GMT-10:00) Hawaii-Aleutian</option>
.. snip ..
</select>
<select name="timezone1" id="timezone1" class="timezone1">
<option value="Pacific/Midway">(GMT-11:00) Midway Island, Samoa</option>
<option value="America/Adak">(GMT-10:00) Hawaii-Aleutian</option>
.. snip ..
</select>
<input type="submit" value="send"> </input>
</form>
<?php
if( isset($_POST['submit']))
{
//be sure to validate and clean your variables
$timezone1 = htmlentities($_POST['timezone1']);
$timezone2 = htmlentities($_POST['timezone2']);
//then you can use them in a PHP function.
function get_timezone_offset( $origin_tz, $remote_tz ) {
$timezone1 = new DateTimeZone( $origin_tz );
$timezone2 = new DateTimeZone( $remote_tz );
$datetime1 = new DateTime("now", $timezone1);
$datetime2 = new DateTime("now", $timezone2);
$offset = $timezone1->getOffset($datetime1) - $timezone2->getOffset($datetime2);
return $offset;
}
}
$offset = get_timezone_offset('datetime1', 'datetime2');
echo $offset/3600;
?>
我不知道我在这里做错了什么!
有人可以帮我解决这个问题吗?