Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在本地时区显示标准时间_Php_Timezone - Fatal编程技术网

Php 如何在本地时区显示标准时间

Php 如何在本地时区显示标准时间,php,timezone,Php,Timezone,使用聊天框,在聊天框中使用raw获取消息时间,我得到了$msg_time=strottime$row[date_time];正确显示strotime值。现在弄不清楚如何用本地时区显示这个 客户端时区 要在其中显示时区的文件 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Title</title> <!

使用聊天框,在聊天框中使用raw获取消息时间,我得到了$msg_time=strottime$row[date_time];正确显示strotime值。现在弄不清楚如何用本地时区显示这个

客户端时区

要在其中显示时区的文件

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Title</title>

    <!-- javascript/jQuery -->
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

    <?php
        session_start();
        echo isset($_SESSION['time']) ? $_SESSION['time'] : "error";
    ?>
</head>
<body>

<script type="text/javascript">
    $(document).ready(function () {
        var visitortime = new Date();
        var visitortimezone = "GMT " + -visitortime.getTimezoneOffset() / 60;
        $.ajax({
            type: "POST",
            url: "timezone.php?XDEBUG_SESSION_START=1",
            data: 'time=' + visitortimezone,
            success: function (data) {

            }
        });
    });
</script>
</body>
</html>
timezone.php

<?php
session_start();
$_SESSION['time'] = $_POST['time'];

您需要显示服务器或客户端时区?如果本地时区是美国/温哥华,该怎么办?日期默认时区设置为“美洲/温哥华”;我不想重复它,我想把它转换成$msg\u time怎么做?$msg\u time=date\u default\u timezone\u get;仍然模棱两可。你想对时区做什么?elseif$\u POST[fetch]==1{$results=mysqli\u query$sql\u con,从SELECT中选择用户、消息、日期和时间*从shout\u box按id排序DESC限制50 shout\u box按shout\u box.id ASC排序;而$row=mysqli\u fetch\u数组$results{date_default_timezone_set'America/Vancouver'$msg_time=date'h:i A M d',strotime$row[date_time];echo.$msg_time..$row[user].'$row[message].}我想在本地时区显示时间,而不是服务器时间
<?php
session_start();
$_SESSION['time'] = $_POST['time'];