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

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

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

      1. 生成类似于 Google Tasks API 的 RFC 3339 时间戳?

        时间:2023-08-07
        <i id='M5FpK'><tr id='M5FpK'><dt id='M5FpK'><q id='M5FpK'><span id='M5FpK'><b id='M5FpK'><form id='M5FpK'><ins id='M5FpK'></ins><ul id='M5FpK'></ul><sub id='M5FpK'></sub></form><legend id='M5FpK'></legend><bdo id='M5FpK'><pre id='M5FpK'><center id='M5FpK'></center></pre></bdo></b><th id='M5FpK'></th></span></q></dt></tr></i><div id='M5FpK'><tfoot id='M5FpK'></tfoot><dl id='M5FpK'><fieldset id='M5FpK'></fieldset></dl></div>
          <bdo id='M5FpK'></bdo><ul id='M5FpK'></ul>

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

                  <tbody id='M5FpK'></tbody>

                  <legend id='M5FpK'><style id='M5FpK'><dir id='M5FpK'><q id='M5FpK'></q></dir></style></legend>
                • <small id='M5FpK'></small><noframes id='M5FpK'>

                  本文介绍了生成类似于 Google Tasks API 的 RFC 3339 时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在构建一个与 Google Tasks 同步的应用.作为同步的一部分,我想比较本地任务和 API 任务,看看哪个最近发生了变化.

                  I am in the process of building an app that syncs with Google Tasks. As part part of the syncing, I want to compare the local task and the API task, and see which one has been changed more recently.

                  来自 Google API 的每个任务都包含一个 updated 属性,如下所示:

                  Each task from Google's API contains an updated property, which looks like this:

                  2011-08-30T13:22:53.108Z
                  

                  现在我想生成一个类似的时间戳,这样每次我更新应用程序上的任务时,它都会设置一个新的 updated 值.要生成我正在使用的 RFC 3339 时间戳 - http:///cbas.pandion.im/2009/10/generating-rfc-3339-timestamps-in.html 生成如下内容:

                  Now I would like to generate a timestamp similar to that, so that every time I update a task on my app it sets a new updated value. To generate the RFC 3339 timestamp I am using - http://cbas.pandion.im/2009/10/generating-rfc-3339-timestamps-in.html which generates something like this:

                  2011-08-30T09:30:16.768-04:00
                  

                  问题是,API 日期总是以大于"本地日期的形式返回,即使本地日期较新也是如此.我猜这与两者之间的不同格式有关.

                  The issue is, the API date is always coming back as "greater" than the local date, even when the local date is newer. I'm guessing it has something to do with the different formatting between the two.

                  这里有两个日期,顶部来自 Google Tasks API(大约 10 分钟前),底部是一分钟前在本地生成的.当比较哪个更大时,它告诉我最高的是.

                  Here are two dates, the top is from the Google Tasks API (from about 10 minutes ago), and the bottom one was generated locally a minute ago. When compared which is greater, it's telling me the top one is.

                  2011-08-30T13:22:53.108Z
                  2011-08-30T09:41:00.735-04:00
                  

                  我的格式错了吗?我在这里做错了什么?非常感谢您对此的任何帮助.

                  Is my formatting wrong? What I am doing wrong here? Any help on this is really appreciated.

                  推荐答案

                  格式是 ISO,所以 new Date().toISOString() 会给你那个格式.正如我正在阅读的那样,可能需要填充:

                  The formatting is ISO so new Date().toISOString() will give you that form. Which as I'm reading might need to be shimmed:

                  /* use a function for the exact format desired... */
                  function ISODateString(d){
                   function pad(n){return n<10 ? '0'+n : n}
                   return d.getUTCFullYear()+'-'
                        + pad(d.getUTCMonth()+1)+'-'
                        + pad(d.getUTCDate())+'T'
                        + pad(d.getUTCHours())+':'
                        + pad(d.getUTCMinutes())+':'
                        + pad(d.getUTCSeconds())+'Z'}
                  
                  var d = new Date();
                  print(ISODateString(d)); // prints something like 2009-09-28T19:03:12Z
                  

                  来源:https://developer.mozilla.org/en/JavaScript/参考/Global_Objects/日期

                  这篇关于生成类似于 Google Tasks API 的 RFC 3339 时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Javascript中的OADate到毫秒时间戳 下一篇:JavaScript 时间戳到 Python 日期时间的转换

                  相关文章

                  最新文章

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

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

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

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