<tfoot id='pFm2g'></tfoot>
<legend id='pFm2g'><style id='pFm2g'><dir id='pFm2g'><q id='pFm2g'></q></dir></style></legend>
    <bdo id='pFm2g'></bdo><ul id='pFm2g'></ul>

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

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

    2. 如何判断时区是否在一年中的任何时候都遵守夏令时?

      How to tell if a timezone observes daylight saving at any time of the year?(如何判断时区是否在一年中的任何时候都遵守夏令时?)

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

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

                <small id='723dK'></small><noframes id='723dK'>

              1. 本文介绍了如何判断时区是否在一年中的任何时候都遵守夏令时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 PHP 中,您可以通过以下方式判断给定日期是否在夏令时期间:

                In PHP, you can tell if a given date is during the Daylight Savings Time period by using something like this:

                $isDST = date("I", $myDate); // 1 or 0
                

                问题在于,这只告诉您该时间点是否在夏令时.是否有可靠的方法来检查 DST 在该时区的任何时间是否有效?

                The problem is that this only tells you whether that one point in time is in DST. Is there a reliable way to check whether DST is in effect at any time in that timezone?

                编辑澄清:

                • 澳大利亚布里斯班一年中的任何时候都不实行夏令时.全年都是 GMT+10.
                • 澳大利亚悉尼从 10 月到 3 月从 GMT+10 变为 GMT+11.

                我想知道是否会有一些现有的方法,或者实现这样的方法的方法:

                I'm wondering if there would be some existing method, or a way to implement a method which works as such:

                timezoneDoesDST('Australia/Brisbane');  // false
                timezoneDoesDST('Australia/Sydney');  // true
                

                推荐答案

                我找到了一个使用 PHP 的 DateTimezone 类(PHP 5.2+)的方法

                I've found a method which works using PHP's DateTimezone class (PHP 5.2+)

                function timezoneDoesDST($tzId) {
                    $tz = new DateTimeZone($tzId);
                    $trans = $tz->getTransitions();
                    return ((count($trans) && $trans[count($trans) - 1]['ts'] > time()));
                }
                

                或者,如果您运行的是 PHP 5.3+

                or, if you're running PHP 5.3+

                function timezoneDoesDST($tzId) {
                    $tz = new DateTimeZone($tzId);
                    return count($tz->getTransitions(time())) > 0;
                }
                

                getTransitions() 函数为您提供有关时区每次偏移量更改的信息.这包括历史数据(布里斯班在 1916 年有夏令时......谁知道?),所以这个函数检查未来是否有偏移变化.

                The getTransitions() function gives you information about each time the offset changes for a timezone. This includes historical data (Brisbane had daylight savings in 1916.. who knew?), so this function checks if there's an offset change in the future or not.

                这篇关于如何判断时区是否在一年中的任何时候都遵守夏令时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 的问题)
                <legend id='LB7cQ'><style id='LB7cQ'><dir id='LB7cQ'><q id='LB7cQ'></q></dir></style></legend>
              2. <small id='LB7cQ'></small><noframes id='LB7cQ'>

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

                        <tbody id='LB7cQ'></tbody>
                        <bdo id='LB7cQ'></bdo><ul id='LB7cQ'></ul>