如何在本地时区显示 strtotime

how to display strtotime in local time zone

使用聊天框获取 msg 时间,据我所知,$msg_time = strtotime($row["date_time"]); 正确显示了 strtotime 值。现在对如何用当地时区显示这个感到困惑

服务器时区

     <?php
        // set the default timezone to use. Available since PHP 5.1
        date_default_timezone_set('UTC');

        echo date("m-d-Y", strtotime('2014-02-21')) . "timezone: " . date_default_timezone_get();

客户端时区

您要在其中显示时区的文件

<!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'];