What is the “right” JSON date format?

前端 未结 16 1374
执念已碎
执念已碎 2020-11-21 15:14

I\'ve seen so many different standards for the JSON date format:

\"\\\"\\\\/Date(1335205592410)\\\\/\\\"\"         .NET JavaScriptSerializer
\"\\\"\\\\/Date(         


        
16条回答
  •  难免孤独
    2020-11-21 16:07

    JSON does not know anything about dates. What .NET does is a non-standard hack/extension.

    I would use a format that can be easily converted to a Date object in JavaScript, i.e. one that can be passed to new Date(...). The easiest and probably most portable format is the timestamp containing milliseconds since 1970.

提交回复
热议问题