最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Swagger and Date - Stack Overflow

programmeradmin0浏览0评论

I'm new to swagger and writing my first spec. I've found following swagger "date" types*:

------------------------------------------------
| Common name        |  Swagger spec 1.2       |
------------------------------------------------
| string             |  string                 |
------------------------------------------------
| date               | string, date            |
------------------------------------------------
| dateTime           | string, date-time       |
------------------------------------------------

Now my timestamp looks like 2014-12-09T13:06:08.260+0000 is this even a Date? It doens't look like the date javascript new Date(); returns. I also haven't found a date type in the json specification.

Which type and format should i take, will it be better to take string instead of a date??

*: note this table is the short version from the swager wiki

I'm new to swagger and writing my first spec. I've found following swagger "date" types*:

------------------------------------------------
| Common name        |  Swagger spec 1.2       |
------------------------------------------------
| string             |  string                 |
------------------------------------------------
| date               | string, date            |
------------------------------------------------
| dateTime           | string, date-time       |
------------------------------------------------

Now my timestamp looks like 2014-12-09T13:06:08.260+0000 is this even a Date? It doens't look like the date javascript new Date(); returns. I also haven't found a date type in the json specification.

Which type and format should i take, will it be better to take string instead of a date??

*: note this table is the short version from the swager wiki

Share Improve this question asked Nov 12, 2014 at 10:09 MemLeakMemLeak 4,6404 gold badges48 silver badges85 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

2014-12-09T13:06:08.260+0000 is a variation of ISO8601 date and time standard. JavaScript Date function can easily parse this format and Date has toISOString() method to produce strings in this format. The only thing is that letter "Z" is usually used to denote GMT/UTC time zone instead of "+0000". But Date can parse it like that too.

发布评论

评论列表(0)

  1. 暂无评论