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

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

  • <tfoot id='o80tl'></tfoot>

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

      1. 使用 JavaScript 将带有时区的日期字符串转换为本地时间的日期对象

        Use JavaScript to convert a date string with timezone to a date object in local time(使用 JavaScript 将带有时区的日期字符串转换为本地时间的日期对象)

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

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

          <legend id='DktyR'><style id='DktyR'><dir id='DktyR'><q id='DktyR'></q></dir></style></legend>
            <bdo id='DktyR'></bdo><ul id='DktyR'></ul>
          • <tfoot id='DktyR'></tfoot>
              <tbody id='DktyR'></tbody>

                • 本文介绍了使用 JavaScript 将带有时区的日期字符串转换为本地时间的日期对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的日期字符串格式如下:yyyy-MM-ddTHH:mm:ss-0Z00

                  The format of my date string looks like this: yyyy-MM-ddTHH:mm:ss-0Z00

                  示例 1:2010-03-05T07:03:51-0800

                  示例 2:2010-07-01T20:23:00-0700

                  我需要使用这些日期字符串创建一个日期对象.new Date() 不适用于此字符串.请帮我将这些日期字符串转换为具有本地时区的日期对象.

                  I need to create a date object using these date strings. new Date() does not work on this string. Please help me convert these date strings into a date objects with the local timezone.

                  谢谢!

                  我在 Pentaho Data Integration 4.3.0 中使用它.

                  I am using this in Pentaho Data Integration 4.3.0.

                  推荐答案

                  可以使用Moment.js等库这样做.

                  查看字符串+格式解析.

                  See the String + Format parsing.

                  http://momentjs.com/docs/#/parsing/string-format/

                  以下应该解析您提供的日期,但您可能需要根据需要对其进行修改.

                  The following should parse your date you provided, but you may need to modify it for your needs.

                  var oldDate = "2010-03-05T07:03:51-0800";
                  
                  var dateObj = moment(oldDate, "YYY-MM-DDTHH:mm:ssZ").toDate();
                  

                  或者,请参阅 Moment 的字符串解析器,它看起来就像您提供的格式,除了时间的秒数和时区之间的空格.

                  Alternatively, see Moment's String parser, which looks like it is in the format you provided, with the exception of a space between the seconds of the time and the time zone.

                  http://momentjs.com/docs/#/parsing/string/

                  第二种方法是 Date.js,另一个似乎可以很好地解析格式的库.http://www.datejs.com

                  A second way of doing this is Date.js, another library that seems to parse the format just fine. http://www.datejs.com

                  这篇关于使用 JavaScript 将带有时区的日期字符串转换为本地时间的日期对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  What are valid deviceNames for Chrome emulation testing with Protractor?(使用 Protractor 进行 Chrome 模拟测试的有效设备名称是什么?)
                  Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
                  Protractor e2e Tests Login Redirection(Protractor e2e 测试登录重定向)
                  Explain about async/ await in Protractor(解释 Protractor 中的 async/await)
                  Protractor browser.wait doesn#39;t wait(量角器 browser.wait 不等待)
                  How to use Protractor with Angular 2?(如何在 Angular 2 中使用量角器?)

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

                  <tfoot id='maKGc'></tfoot>
                • <legend id='maKGc'><style id='maKGc'><dir id='maKGc'><q id='maKGc'></q></dir></style></legend>

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

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