Wedding and date

I am new to swagger and writing my first specification. I found the following 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 that even a date? It is not like javascript new Date(); . I also did not find the date type in the json specification .

What type and format should be taken, is it better to take a string instead of a date?

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

+6
source share
1 answer

2014-12-09T13:06:08.260+0000 is a variant of the ISO8601 date and time standard . The JavaScript Date function can easily toISOString() this format, and Date has a toISOString() method to create strings in this format. The only thing is that the letter "Z" is usually used to indicate GMT / UTC time zone instead of "+0000". But Date can also understand this.

+7
source

Source: https://habr.com/ru/post/978078/


All Articles