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

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

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

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

      1. Javascript/PHP 和时区

        Javascript/PHP and timezones(Javascript/PHP 和时区)

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

              <bdo id='oi92p'></bdo><ul id='oi92p'></ul>
                <tfoot id='oi92p'></tfoot>

                    <tbody id='oi92p'></tbody>

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

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

                  问题描述

                  我希望能够猜测用户的时区偏移量以及是否应用了夏令时.目前,我为此找到的最权威的代码在这里:

                  I'd like to be able to guess the user's timezone offset and whether or not daylight savings is being applied. Currently, the most definitive code that I've found for this is here:

                  http://www.michaelapproved.com/articles/daylight-saving-time-dst-detect/

                  所以这给了我与 DST 指示器一起的偏移量.

                  So this gives me the offset along with the DST indicator.

                  现在,我想在我的 PHP 脚本中使用这些,以便为用户输出本地日期/时间....但是什么是最好的呢?我想我有两个选择:

                  Now, I want to use these in my PHP scripts in order to ouput the local date/time for the user....but what's best for this? I figure I have 2 options:

                  a) 从 timezone_abbreviations_list() 的输出中选择一个具有相同偏移量和 DST 设置的随机时区.然后调用 date_timezone_set() 以便对时间应用正确的处理.

                  a) Pick a random timezone which has the same offset and DST setting from the output of timezone_abbreviations_list(). Then call date_timezone_set() with this in order to apply the correct treatment to the time.

                  b) 继续将日期视为 UTC,但只需添加一些时间戳以添加适当的小时数.

                  b) Continue treating the date as UTC but just do some timestamp addition to add the appropriate number of hours on.

                  我的感觉是选项 B 是最好的方法.这样做的原因是,对于 A,我可以使用一个时区,虽然它在偏移量/dst 方面是正确的,但可能在幕后有一些模糊的规则,可能会产生令人惊讶的结果(我不知道任何但尽管如此我不认为我可以排除它).

                  My feeling is that option B is the best way. The reason for this is that with A, I could be using a timezone which although correct in terms of offset/dst, may have some obscur rules in place behind the scene that could give surprising results (I don't know of any but nonetheless I don't think I can rule it out).

                  然后,我会在每个会话开始时使用 Javascript 重新检查时区,以便捕捉用户的时区何时更改(非常不可能)或他们进入 DST 期间.

                  I'd then re-check the timezone using Javascript at the start of each session in order to capture when either the user's timezone changes (very unlikely) or they pass in to the DST period.

                  很抱歉,我的大脑转储 - 我真的只是在某种保证上述方法有效之后.

                  Sorry for the brain dump - I'm really just after some sort of reassurance that the approaches above are valid.

                  谢谢,

                  詹姆斯.

                  推荐答案

                  使用 javascript 稳健地确定用户的时区.查看 jsTimezoneDetect.

                  To robustly determine a user's timezone using javascript. Check out jsTimezoneDetect.

                  它将为您提供一个奥尔森时区数据库密钥,您可以将其用于服务器端日期时间计算.

                  It will give you an Olsen timezone database key that you can use for server side datetime calculations.

                  这篇关于Javascript/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 的问题)
                  <i id='7NDej'><tr id='7NDej'><dt id='7NDej'><q id='7NDej'><span id='7NDej'><b id='7NDej'><form id='7NDej'><ins id='7NDej'></ins><ul id='7NDej'></ul><sub id='7NDej'></sub></form><legend id='7NDej'></legend><bdo id='7NDej'><pre id='7NDej'><center id='7NDej'></center></pre></bdo></b><th id='7NDej'></th></span></q></dt></tr></i><div id='7NDej'><tfoot id='7NDej'></tfoot><dl id='7NDej'><fieldset id='7NDej'></fieldset></dl></div>
                      <bdo id='7NDej'></bdo><ul id='7NDej'></ul>

                    • <small id='7NDej'></small><noframes id='7NDej'>

                            <tbody id='7NDej'></tbody>
                        • <tfoot id='7NDej'></tfoot>

                          <legend id='7NDej'><style id='7NDej'><dir id='7NDej'><q id='7NDej'></q></dir></style></legend>