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

    <legend id='Itwe4'><style id='Itwe4'><dir id='Itwe4'><q id='Itwe4'></q></dir></style></legend>

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

        • <bdo id='Itwe4'></bdo><ul id='Itwe4'></ul>
        <tfoot id='Itwe4'></tfoot>

        在 PHP 中的时区之间转换

        时间:2024-08-15

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

          • <legend id='FGRqH'><style id='FGRqH'><dir id='FGRqH'><q id='FGRqH'></q></dir></style></legend>

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

                  <bdo id='FGRqH'></bdo><ul id='FGRqH'></ul>

                  本文介绍了在 PHP 中的时区之间转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在转换这个时间和日期:

                  I am converting this time and date:

                  Thu, 31 Mar 2011 02:05:59 GMT
                  

                  转为以下时间日期格式:

                  To the following time and date format:

                  Monday March 28 2011 4:48:02 PM
                  

                  我正在使用以下 PHP 代码来完成此操作,但我想将所有时区转换为 PST/PDT.我查看了 PHP 手册并看到了这个 date_default_timezone_set() 但我不确定如何在下面的代码中实现它.

                  I am using the following PHP code to accomplish this, but I want to convert all time zones to PST/PDT. I looked at the PHP manual and saw this date_default_timezone_set() but I am not sure how to implement that into the code I have below.

                  $date = $messages[0]->CreationTime;
                  echo date('l F j Y g:i:s A I', strtotime($date))
                  

                  推荐答案

                  我不会将 date_default_timezone_set 用于一般的 TZ 转换.(澄清一下......如果这是出于显示目的,脚本范围,那么使用默认时区是合理的做法.)

                  I would not use date_default_timezone_set for general TZ conversions. (To clarify... if this is for display purposes, script wide, then using the default timezone is a reasonable thing to do.)

                  相反,我会使用类似的东西:

                  Instead, I would use something like:

                  $tz = new DateTimeZone('America/Los_Angeles');
                  
                  $date = new DateTime('Thu, 31 Mar 2011 02:05:59 GMT');
                  $date->setTimezone($tz);
                  echo $date->format('l F j Y g:i:s A I')."
                  ";
                  

                  这篇关于在 PHP 中的时区之间转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP - strtotime,指定时区 下一篇:没有了

                  相关文章

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

                    <tfoot id='mVV9q'></tfoot>

                      • <bdo id='mVV9q'></bdo><ul id='mVV9q'></ul>
                      <legend id='mVV9q'><style id='mVV9q'><dir id='mVV9q'><q id='mVV9q'></q></dir></style></legend>

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