久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='OVSPj'></tfoot>

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

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

        在 Javascript 中使用時區和夏令時

        Working with timezones and daylight savings time in Javascript(在 Javascript 中使用時區和夏令時)

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

        <tfoot id='IdgZl'></tfoot>
        <legend id='IdgZl'><style id='IdgZl'><dir id='IdgZl'><q id='IdgZl'></q></dir></style></legend>

            • <i id='IdgZl'><tr id='IdgZl'><dt id='IdgZl'><q id='IdgZl'><span id='IdgZl'><b id='IdgZl'><form id='IdgZl'><ins id='IdgZl'></ins><ul id='IdgZl'></ul><sub id='IdgZl'></sub></form><legend id='IdgZl'></legend><bdo id='IdgZl'><pre id='IdgZl'><center id='IdgZl'></center></pre></bdo></b><th id='IdgZl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='IdgZl'><tfoot id='IdgZl'></tfoot><dl id='IdgZl'><fieldset id='IdgZl'></fieldset></dl></div>
                <tbody id='IdgZl'></tbody>
                  <bdo id='IdgZl'></bdo><ul id='IdgZl'></ul>
                  本文介紹了在 Javascript 中使用時區和夏令時的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我的單頁 javascript 應用程序通過 REST 調用以 JSON 格式檢索數據.日期使用標準 ISO8601 格式的 UTC 時區格式化,例如 2011-02-04T19:31:09Z.

                  My single-page javascript app retrieves data in JSON format via REST calls. Dates come formatted using the UTC timezone in standard ISO8601 format, such as 2011-02-04T19:31:09Z.

                  注冊服務時,用戶從下拉列表中選擇他們的時區.此時區可能與用戶瀏覽器的時區不同.javascript 應用程序始終知道用戶選擇的時區.

                  When signing up for the service, users select their timezone from a drop down list. This timezone could be different than the user's browser's timezone. The javascript app knows what the user's selected timezone is at all times.

                  我知道如何將 UTC 字符串轉換為日期.我了解 Javascript 僅代表本地時區的日期.

                  I know how to convert the UTC string into a date. I understand that Javascript only represents dates in the local timezone.

                  但我無法弄清楚如何顯示針對用戶本地時區以外的時區格式化的日期.它必須考慮所有日期的 DST.在內部,我想將所有日期作為 UTC 處理,并且只在顯示時間轉換為另一個時區中日期的字符串表示形式.我需要在用戶個人資料中選擇的時區顯示日期,而不是他們瀏覽器的時區.

                  But I'm having troubles figuring out how to display a date formatted for a timezone OTHER than the user's local timezone. It must account for DST on all dates. Internally, I want to deal with all dates as UTC and only convert to string representation of a date in another timezone at display time. I need to display the dates in the timezone selected in the user's profile, not their browser's timezone.

                  我已經嘗試使用服務器發送用戶瀏覽器時區和用戶配置文件時區之間的時區偏移差異(以毫秒為單位).但我發現我不能只發送一個偏移量值,而是需要為每個日期發送一個偏移量以說明 DST 的變化.

                  I've experimented with the server sending the timezone offset difference in milliseconds between the user's browser's timezone and the user's profile timezone. But I've found I can't just send one offset value, but need to send an offset for every date to account for variations in DST.

                  關于如何顯示不同時區格式的日期的任何建議或示例代碼?到目前為止我發現的選項:

                  Any suggestions or sample code on how to display dates formatted in various timezones? The options I've found so far:

                  1. 服務器將日期作為已在正確時區格式化的字符串發送,并且沒有在客戶端上進行日期解析或操作.這使得在客戶端上做某些事情即使不是不可能也很困難.
                  2. 使用庫,例如?? https://github.com/mde/timezone-js,其中包括整個 Olson TZ 數據庫到 Javascript.這意味著更長的加載時間更多的內存使用等.
                  3. 發送一個 timezoneOffsetMillis 值以及每個發送給客戶端的日期.這會導致混亂的 JSON 數據和非最佳 REST 接口.
                  1. Server sends dates as strings already formatted in the right timezone and no date parsing or manipulation is done on the client. This makes doing certain things on the client difficult if not impossible.
                  2. Use a library such as https://github.com/mde/timezone-js, which includes the entire Olson TZ database into Javascript. This means longer load times more memory usage, etc.
                  3. Send a timezoneOffsetMillis value with every date sent to the client. This results in messy JSON data and non-optimal REST interfaces.

                  有沒有更簡單或更好的解決方案?

                  Are there any simpler or better solutions?

                  推薦答案

                  2 是個壞主意,因為正如您所指出的,它會增加加載時間.如果我是你,我會做 1 和 3 的組合.我不同意這會導致 JSON 數據混亂或 REST 接口非最優.

                  2 is a bad idea since, as you pointed out, it increases load times. If I were you I would do a combination of 1 and 3. I don't agree that this makes the JSON data messy or the REST interface non-optimal.

                  這是一個經典的權衡,在協議中接受更多的復雜性以簡化客戶端代碼.

                  This is a classic tradeoff where to accept a bit more complexity in the protocol in order to simplify the client-side code.

                  這篇關于在 Javascript 中使用時區和夏令時的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                • <small id='TkOZL'></small><noframes id='TkOZL'>

                  <tfoot id='TkOZL'></tfoot>

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

                          • <bdo id='TkOZL'></bdo><ul id='TkOZL'></ul>
                              <tbody id='TkOZL'></tbody>

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

                            主站蜘蛛池模板: 精品一区二区不卡 | 久久久久久久久久一区二区 | 精品国产一区二区三区免费 | 午夜黄色 | 91视频在线| 中文字幕亚洲专区 | 99精品一区二区 | 中文字幕乱码一区二区三区 | dy天堂| 国产精品久久国产精品 | 午夜午夜精品一区二区三区文 | 国产亚洲一区二区精品 | 日韩成人免费视频 | 中文字幕亚洲精品在线观看 | 国产人成精品一区二区三 | 欧美在线视频不卡 | 国产成人99久久亚洲综合精品 | 亚洲五码在线 | 欧美视频一区 | 国产精品1区 | 亚洲黄色成人网 | 久久91精品久久久久久9鸭 | 一区二区三区四区在线免费观看 | www免费视频 | 国产成人一区二区三区精 | 午夜免费视频 | 日本黄色不卡视频 | 国产乱性| 日韩无| 成人久草| 一区日韩 | 国产精品自产拍在线观看蜜 | 玖玖视频免费 | 国产中文字幕亚洲 | 99久久精品免费看国产高清 | 精品视频一区二区三区四区 | 亚洲97 | 国产成人免费视频网站高清观看视频 | 日韩av一区二区在线观看 | 很黄很污的网站 | 91精品国产乱码久久蜜臀 |