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

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

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

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

      1. HTML 輸入類型 datetime-local 設置錯誤的時區

        HTML Input type datetime-local setting the wrong time-zone(HTML 輸入類型 datetime-local 設置錯誤的時區)
        <legend id='jAh1d'><style id='jAh1d'><dir id='jAh1d'><q id='jAh1d'></q></dir></style></legend>
          <tbody id='jAh1d'></tbody>

        1. <tfoot id='jAh1d'></tfoot>
            1. <small id='jAh1d'></small><noframes id='jAh1d'>

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

                  本文介紹了HTML 輸入類型 datetime-local 設置錯誤的時區的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我創建了一個應用程序,它接受 HTML 輸入并通過 JavaScript 在本機日歷事件上創建一個事件.它從 <input type="datetime-local"> 中花費時間,并且由于選擇了不同的時區,因此它輸入了不同的時間.如果我輸入 1 o'clock PM 作為時間,它將返回 8 o'clock AM.

                  I've created an app that takes in HTML inputs and goes through JavaScript to create an event on a native calendar events. It takes the time from the <input type="datetime-local">, and it's putting in a different time because it's picking a different time zone. If I enter 1 o'clock PM as a time it will return 8 o'clock AM.

                  <input type="datetime-local" id="startDate" name="startDate">
                  

                  還有 JavaScript:

                  And the JavaScript:

                  var startDate = new Date($("#startDate").val());
                  

                  任何幫助都會很棒.如果需要,我可以發布更多代碼.

                  Any help would be awesome. I can post more code if needed.

                  推薦答案

                  HTML5 datetime-local 輸入類型將返回一個 string 值,其中包含日期和 ISO8601 格式的時間,精確到分鐘,沒有任何時區偏移.

                  The HTML5 datetime-local input type will give you a string value back, which contains the date and time in ISO8601 format, with minute precision, and without any time zone offset.

                  例如:2014-07-12T01:00

                  JavaScript 日期對象在從字符串中解析日期時是出了名的不一致.在大多數實現中,當您提供這樣的字符串時,它會錯誤地假定該值是 UTC.因此,您返回的 Date 對象將根據您本地計算機的時區偏移量進行調整.

                  The JavaScript date object is notoriously inconsistent when it comes to parsing dates from strings. In most implementations, when you provide a string like this, it erroneously assumes the value is in UTC. Therefore, the Date object you get back will be adjusted by the time zone offset from your local computer.

                  有兩種方法可以解決這個問題:

                  There are two approaches to work around the problem:

                  選項 1

                  將字符串處理為可能被 Date 對象的解析器解釋為本地時間的格式.具體來說,將破折號 (-) 替換為正斜杠 (/),并將 T 替換為空格.

                  Manipulate the string to a format that will likely be interpreted as local time by the Date object's parser. Specifically, replace the dashes (-) with forward slashes (/) and replace the T with a space.

                  var s = $("#startDate").val();
                  var startDate = new Date(s.replace(/-/g,'/').replace('T',' '));
                  

                  選項 2

                  使用具有更強大的日期解析能力的庫.有幾種可用.其中最流行的是 moment.js.

                  Use a library with more capable date parsing abilities. There are several available. One of the most popular is moment.js.

                  Moment.js 有很多選項,但碰巧默認行為正是您所需要的.因此,您可以將字符串傳遞給 moment 構造函數而無需任何參數.

                  Moment.js has lots of options, but it just so happens that the default behavior is exactly what you need. So you can just pass the string to the moment constructor without any parameters.

                  var s = $("#startDate").val();
                  var startDate = moment(s).toDate();
                  

                  這篇關于HTML 輸入類型 datetime-local 設置錯誤的時區的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='UE2Gb'></small><noframes id='UE2Gb'>

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

                    • <bdo id='UE2Gb'></bdo><ul id='UE2Gb'></ul>

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

                              <tbody id='UE2Gb'></tbody>
                          • 主站蜘蛛池模板: 91免费高清视频 | 激情欧美日韩一区二区 | 免费久久网 | 欧美精品欧美精品系列 | 国产高清免费视频 | 欧美日韩一区不卡 | www.国产视频 | 久久精品一区 | 尤物视频在线免费观看 | 日韩欧美一级片 | 一区二区三区四区不卡 | 亚洲精品视频在线播放 | 欧美在线国产精品 | 免费黄色的视频 | 午夜久久久久久久久久一区二区 | 毛片1 | 欧美激情精品久久久久久变态 | 免费99视频 | 天天操网 | 亚洲欧美精品在线观看 | 亚洲综合热 | 热99视频| 久久中文字幕一区 | 国产亚洲精品精品国产亚洲综合 | 欧美一区二区三区日韩 | 欧美成年黄网站色视频 | 亚洲欧美日韩精品久久亚洲区 | 激情网站在线 | 中文字幕在线不卡 | 男人的天堂亚洲 | 欧美久久久久久久 | 中文字幕第九页 | 欧美黄色录像 | 久久久久久国产精品免费免费男同 | 久久久精品影院 | 在线免费观看黄色 | 免费的一级视频 | 久久成人国产 | 国产精品揄拍一区二区 | 久久精品一级 | 亚洲国产二区 |