Generate an RFC 3339 timestamp similar to Google Tasks API?

前端 未结 7 2211
时光取名叫无心
时光取名叫无心 2020-12-02 20:45

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 be

7条回答
  •  日久生厌
    2020-12-02 21:13

    I've found the moment.js library nice for working with time in javascript. moment().format() yields a timestamp in the format expected by the Google API for a datetime. Or, to not depend on the default format being correct for your application,

    moment().format("YYYY-MM-DDTHH:mm:ssZ")
    

    All the string options (including fractional seconds if that's what you need): http://momentjs.com/docs/#/displaying/format/

提交回复
热议问题