php 如何显示菲律宾的默认本地时区?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25905053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:02:01  来源:igfitidea点击:

How to show default local time zone of Philippines?

phptimezone

提问by Tuper Evangelista

How can I show the local date and time for Philippines?

如何显示菲律宾的当地日期和时间?

<? php
    date_default_timezone_set('Asia/Manila');
    echo "<span style='color:red;font-weight:bold;'>Date: </span>". date('F j, Y g:i:a  ');
?>

回答by worldask

You shouldn't add space between <?and php

你不应该在<?和之间添加空格php

<?php
date_default_timezone_set('Asia/Manila');
echo "<span style='color:red;font-weight:bold;'>Date: </span>". date('F j, Y g:i:a  ');
?>

回答by besciualex

As @worldask already sad you shouldn't add space between those <? php. The rest of the code is good. The reason why you don't get the date you want, is that the server's time is different than you think it is. When the PHP engine adds 8 hours to his system dateit gives you a good result. In order to check which is the current hour and debug your problem use the following code, then fix the system's date.

由于@worldask 已经很难过,您不应该在它们之间添加空格<? php。其余的代码很好。你没有得到你想要的日期的原因是服务器的时间与你想象的不同。当 PHP 引擎在他的系统日期上增加 8 小时时,它会给你一个很好的结果。为了检查哪个是当前小时并调试您的问题,请使用以下代码,然后修复系统的日期。

<?php
echo "Current timezone: ".date_default_timezone_get()."</ br>
      Current time: ".date("d-m-Y H:i:s");
?>