<i id='ZaI9B'><tr id='ZaI9B'><dt id='ZaI9B'><q id='ZaI9B'><span id='ZaI9B'><b id='ZaI9B'><form id='ZaI9B'><ins id='ZaI9B'></ins><ul id='ZaI9B'></ul><sub id='ZaI9B'></sub></form><legend id='ZaI9B'></legend><bdo id='ZaI9B'><pre id='ZaI9B'><center id='ZaI9B'></center></pre></bdo></b><th id='ZaI9B'></th></span></q></dt></tr></i><div id='ZaI9B'><tfoot id='ZaI9B'></tfoot><dl id='ZaI9B'><fieldset id='ZaI9B'></fieldset></dl></div>

  1. <tfoot id='ZaI9B'></tfoot>

    1. <legend id='ZaI9B'><style id='ZaI9B'><dir id='ZaI9B'><q id='ZaI9B'></q></dir></style></legend>
    2. <small id='ZaI9B'></small><noframes id='ZaI9B'>

      • <bdo id='ZaI9B'></bdo><ul id='ZaI9B'></ul>

      在 php 中获取服务器时间 - 时区问题

      get server time in php - timezone issues(在 php 中获取服务器时间 - 时区问题)

          <small id='7Kc2T'></small><noframes id='7Kc2T'>

          <i id='7Kc2T'><tr id='7Kc2T'><dt id='7Kc2T'><q id='7Kc2T'><span id='7Kc2T'><b id='7Kc2T'><form id='7Kc2T'><ins id='7Kc2T'></ins><ul id='7Kc2T'></ul><sub id='7Kc2T'></sub></form><legend id='7Kc2T'></legend><bdo id='7Kc2T'><pre id='7Kc2T'><center id='7Kc2T'></center></pre></bdo></b><th id='7Kc2T'></th></span></q></dt></tr></i><div id='7Kc2T'><tfoot id='7Kc2T'></tfoot><dl id='7Kc2T'><fieldset id='7Kc2T'></fieldset></dl></div>
          <tfoot id='7Kc2T'></tfoot>
            <tbody id='7Kc2T'></tbody>
            <legend id='7Kc2T'><style id='7Kc2T'><dir id='7Kc2T'><q id='7Kc2T'></q></dir></style></legend>

              <bdo id='7Kc2T'></bdo><ul id='7Kc2T'></ul>
                本文介绍了在 php 中获取服务器时间 - 时区问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 shell 上,我的服务器时间是(简单的 date in bash):2010 年 8 月 29 日星期日 10:37:12 EDT

                on shell, my server time is (simple date in bash): Sun Aug 29 10:37:12 EDT 2010

                当我运行代码 php -r "echo date('Y-m-d H:i:s');" 我得到:2010-08-29 10:37:10

                when I run the code php -r "echo date('Y-m-d H:i:s');" I get: 2010-08-29 10:37:10

                但是当我执行一个具有 echo date('Ymd H:i:s'); 的 php 脚本时,我得到一个不同的时间 - 因为 php 认为时区是 UTC(服务器时间是 EDT).

                but when I execute a php script that has echo date('Y-m-d H:i:s'); I get a different time- since php thinks the timezone is UTC (server time is EDT).

                我的 php.ini 文件没有设置时区,我不想更改任何内容 - 因为我不知道它会对在此服务器上运行的其他站点产生什么影响.

                My php.ini file has no timezone set, and I wouldnt like to change anything- as I have no idea what affect it would have on other sites that run on this server.

                有没有一种简单的方法可以在为服务器设置的时区获取服务器时间?

                Is there a simple way to get the server time- at the timezone that is set for the server?

                推荐答案

                根据php.ini 指令 手册页,如果您使用的是 5.3 之前的版本,则默认情况下不设置时区.然后,如果您查看 的页面date_default_timezone_get,它使用以下顺序获取时区:

                According to the php.ini directives manual page, the timezone isn't set by default if you're using a version prior to 5.3. Then if you take a look at the page for date_default_timezone_get, it uses the following order for getting the timezone:

                * Reading the timezone set using the date_default_timezone_set() function (if any)
                * Reading the TZ environment variable (if non empty) (Prior to PHP 5.3.0)
                * Reading the value of the date.timezone ini option (if set)
                * Querying the host operating system (if supported and allowed by the OS)
                

                如果所有这些都失败,则 UTC 是默认值,所以这可能是一个很好的起点.

                UTC is the default if all of those fail, so that's probably a good starting point.

                这篇关于在 php 中获取服务器时间 - 时区问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='v9vbe'></small><noframes id='v9vbe'>

                      <bdo id='v9vbe'></bdo><ul id='v9vbe'></ul>
                        <tbody id='v9vbe'></tbody>
                      <legend id='v9vbe'><style id='v9vbe'><dir id='v9vbe'><q id='v9vbe'></q></dir></style></legend>

                        <i id='v9vbe'><tr id='v9vbe'><dt id='v9vbe'><q id='v9vbe'><span id='v9vbe'><b id='v9vbe'><form id='v9vbe'><ins id='v9vbe'></ins><ul id='v9vbe'></ul><sub id='v9vbe'></sub></form><legend id='v9vbe'></legend><bdo id='v9vbe'><pre id='v9vbe'><center id='v9vbe'></center></pre></bdo></b><th id='v9vbe'></th></span></q></dt></tr></i><div id='v9vbe'><tfoot id='v9vbe'></tfoot><dl id='v9vbe'><fieldset id='v9vbe'></fieldset></dl></div>
                        • <tfoot id='v9vbe'></tfoot>