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

    1. <small id='nil9E'></small><noframes id='nil9E'>

    2. <legend id='nil9E'><style id='nil9E'><dir id='nil9E'><q id='nil9E'></q></dir></style></legend>
      <i id='nil9E'><tr id='nil9E'><dt id='nil9E'><q id='nil9E'><span id='nil9E'><b id='nil9E'><form id='nil9E'><ins id='nil9E'></ins><ul id='nil9E'></ul><sub id='nil9E'></sub></form><legend id='nil9E'></legend><bdo id='nil9E'><pre id='nil9E'><center id='nil9E'></center></pre></bdo></b><th id='nil9E'></th></span></q></dt></tr></i><div id='nil9E'><tfoot id='nil9E'></tfoot><dl id='nil9E'><fieldset id='nil9E'></fieldset></dl></div>
      1. <tfoot id='nil9E'></tfoot>

        您如何处理 PHP 中的时区差异计算?

        时间:2024-08-14
          <bdo id='iw1WR'></bdo><ul id='iw1WR'></ul>

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

            1. <legend id='iw1WR'><style id='iw1WR'><dir id='iw1WR'><q id='iw1WR'></q></dir></style></legend><tfoot id='iw1WR'></tfoot>
              <i id='iw1WR'><tr id='iw1WR'><dt id='iw1WR'><q id='iw1WR'><span id='iw1WR'><b id='iw1WR'><form id='iw1WR'><ins id='iw1WR'></ins><ul id='iw1WR'></ul><sub id='iw1WR'></sub></form><legend id='iw1WR'></legend><bdo id='iw1WR'><pre id='iw1WR'><center id='iw1WR'></center></pre></bdo></b><th id='iw1WR'></th></span></q></dt></tr></i><div id='iw1WR'><tfoot id='iw1WR'></tfoot><dl id='iw1WR'><fieldset id='iw1WR'></fieldset></dl></div>
                    <tbody id='iw1WR'></tbody>
                  本文介绍了您如何处理 PHP 中的时区差异计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有人告诉我,以下计算用户当地时间的方法有时不起作用.在 PHP 中执行此操作的最佳方法是什么?你是做什么的?

                  I'm being told that this below method of calculating the user's local time is sometimes not working. What's the best way to do this in PHP? What do you do?

                  public function getTimeOffset ($time) {
                      $this->_cacheTimeOffset();  
                      if ($this->timeOffsetExecuted) {
                          $d = date("O");
                          $neg = 1;
                  
                          if (substr($d, 0, 1) == "-") {
                              $neg = -1;
                              $d = substr($d, 1);
                          }
                  
                          $h = substr($d, 0, 2)*3600;
                          $m = substr($d, 2)*60;
                  
                          return $time + ($neg * ($h + $m) * -1) + (($this->timeOffset + $this->getDstInUse()) * 3600);
                      }
                      return $time;
                  }
                  

                  推荐答案

                  使用 DateTime 扩展,例如 日期时间::getOffset,
                  或 DateTimeZone::getOffset

                  Use the DateTime extension, such as DateTime::getOffset,
                  or DateTimeZone::getOffset

                  某些国家/地区可能会执行多次时区更新,
                  这个方法DateTimeZone::getTransitions 显示转换历史

                  Some countries might have perform several timezone update,
                  this method DateTimeZone::getTransitions reveal the transition history

                  这篇关于您如何处理 PHP 中的时区差异计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用php将时间转换为不同的时区 下一篇:您如何检测网站访问者的国家/地区(特别是美国与否)?

                  相关文章

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

                    • <bdo id='1QwEi'></bdo><ul id='1QwEi'></ul>
                    <tfoot id='1QwEi'></tfoot>

                    <small id='1QwEi'></small><noframes id='1QwEi'>