【问题标题】:MomentJS toISOString with local timezoneMomentJS toISOString 与本地时区
【发布时间】:2014-10-12 17:19:43
【问题描述】:

在通过 jQuery 发送到服务器之前,我一直在使用 toISOString 序列化 momentJS 日期。它对我来说很好,除了它将日期转换为 UTC 但我需要保留本地时区。 momentJS 有这个方法吗?

【问题讨论】:

    标签: momentjs


    【解决方案1】:

    您可以不带任何参数直接调用.format()

    【讨论】:

      【解决方案2】:

      在 2.20.0 中添加:

      moment().toISOString(true)
      

      输出:

      "2018-05-13T16:16:13.507+03:00"
      

      找到答案here

      Documentation.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-08
        • 2012-06-05
        • 1970-01-01
        • 2016-01-19
        • 1970-01-01
        • 2018-01-22
        • 2020-04-27
        相关资源
        最近更新 更多