Javascript 如何为jsonschema生成时间字符串

Javascript 如何为jsonschema生成时间字符串,javascript,python,jsonschema,Javascript,Python,Jsonschema,我有这样一个模式: "foo": {"type": "string", "format": "time"} 我尝试了new(new Date())。toISOString()它有以下格式: "2018-06-12T08:59:01.135Z" 错误: jsonschema.exceptions.ValidationError: '2018-06-12T08:59:01.135Z' is not a 'time' 您可以将日期转换为json() {“格式”:“时间”}使用RFC-3339第5

我有这样一个模式:

"foo": {"type": "string", "format": "time"}
我尝试了
new(new Date())。toISOString()
它有以下格式:

"2018-06-12T08:59:01.135Z"
错误:

jsonschema.exceptions.ValidationError: '2018-06-12T08:59:01.135Z' is not a 'time'

您可以将日期
转换为json()

{“格式”:“时间”}
使用RFC-3339第5.6节“互联网日期/时间格式”


尝试不转换为StringTo不转换为iso StringNot work…时间格式必须只包含时间,而不是日期。要包含日期和时间,请使用“日期-时间”。看见
new Date().toJSON()