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

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

  • <small id='yrWGK'></small><noframes id='yrWGK'>

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

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

        <tfoot id='yrWGK'></tfoot>
      1. 在特定時區格式化日期

        Format date in a specific timezone(在特定時區格式化日期)

          <tbody id='rrTg9'></tbody>

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

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

                  本文介紹了在特定時區格式化日期的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 Moment.js 在我的網絡應用程序中解析和格式化日期.作為 JSON 對象的一部分,我的后端服務器以 UTC 紀元(Unix 偏移量)的毫秒數發送日期.

                  I'm using Moment.js to parse and format dates in my web app. As part of a JSON object, my backend server sends dates as a number of milliseconds from the UTC epoch (Unix offset).

                  在特定時區解析日期很容易——只需在解析前將 RFC 822 時區標識符附加到字符串的末尾即可:

                  Parsing dates in a specific timezone is easy -- just append the RFC 822 timezone identifier to the end of the string before parsing:

                  // response varies according to your timezone
                  const m1 = moment('3/11/2012 13:00').utc().format("MM/DD HH:mm")
                  
                  // problem solved, always "03/11 17:00"
                  const m2 = moment('3/11/2012 13:00 -0400').utc().format("MM/DD HH:mm")
                  
                  console.log({ m1, m2 })

                  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>

                  但是如何在特定時區格式化日期?

                  無論瀏覽器的當前時間如何,我都想要一致的結果,但我不想以 UTC 顯示日期.

                  I want consistent results regardless of the browser's current time, but I don't want to display dates in UTC.

                  推薦答案

                  正如Manto's answer中指出的,.utcOffset() 是 Moment 的首選方法2.9.0.此函數使用與 UTC 的實際偏移量,而不是反向偏移量(例如,DST 期間的紐約為 -240).像+0400"這樣的偏移字符串的工作方式和以前一樣:

                  As pointed out in Manto's answer, .utcOffset() is the preferred method as of Moment 2.9.0. This function uses the real offset from UTC, not the reverse offset (e.g., -240 for New York during DST). Offset strings like "+0400" work the same as before:

                  // always "2013-05-23 00:55"
                  moment(1369266934311).utcOffset(60).format('YYYY-MM-DD HH:mm')
                  moment(1369266934311).utcOffset('+0100').format('YYYY-MM-DD HH:mm')
                  

                  較舊的 .zone() 作為二傳手在 Moment.js 2.9.0 中被棄用.它接受包含時區標識符的字符串(例如,-4 小時的-0400"或-04:00")或代表 UTC 分鐘的數字(例如,DST 期間紐約的 240).

                  The older .zone() as a setter was deprecated in Moment.js 2.9.0. It accepted a string containing a timezone identifier (e.g., "-0400" or "-04:00" for -4 hours) or a number representing minutes behind UTC (e.g., 240 for New York during DST).

                  // always "2013-05-23 00:55"
                  moment(1369266934311).zone(-60).format('YYYY-MM-DD HH:mm')
                  moment(1369266934311).zone('+0100').format('YYYY-MM-DD HH:mm')
                  

                  <小時>

                  要使用命名時區而不是數字偏移量,請包含 Moment Timezone 并使用 .tz() 改為:

                  // determines the correct offset for America/Phoenix at the given moment
                  // always "2013-05-22 16:55"
                  moment(1369266934311).tz('America/Phoenix').format('YYYY-MM-DD HH:mm')
                  

                  這篇關于在特定時區格式化日期的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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() 的限制?)

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

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

                        <legend id='ZHG1x'><style id='ZHG1x'><dir id='ZHG1x'><q id='ZHG1x'></q></dir></style></legend>
                              <tbody id='ZHG1x'></tbody>

                            主站蜘蛛池模板: 亚洲视频在线看 | 欧美成人h版在线观看 | 久久在线 | www在线视频 | 成人免费视频网站在线看 | 精品中文字幕在线 | 国产在线小视频 | 久久新 | 亚洲午夜在线 | 精品亚洲一区二区 | 久久一区二区精品 | 久久精品亚洲精品国产欧美 | 欧美日韩一区二区三区不卡视频 | 91视频进入 | 欧美舔穴| 国产精品久久久久久久久免费 | av在线免费播放 | 黄色片视频免费 | 插插插干干干 | 91视频网| 午夜视频网站 | 美女在线国产 | 日日操天天射 | 亚洲高清免费 | www.国产精 | 一区二区三区欧美 | 久久国内 | 国产精品夜夜夜一区二区三区尤 | 一区二区三区四区毛片 | 日韩成人精品一区 | 99热热热| 九九精品在线 | av黄色片在线观看 | 亚洲成人一区二区三区 | 欧美久久久久久 | 欧美激情综合网 | 91免费看片 | 亚洲中字在线 | 欧美三级视频在线观看 | 亚洲社区在线 | 欧美精品在线播放 |