JSON Generator上的日期格式

时间:2018-09-25 15:06:56

标签: javascript json

我会在JSON-GENERATOR上生成JSON对象

我希望日期具有以下格式:2017-12-31

[
  '{{repeat(5, 7)}}',
  {
    equityPriceList: [
      {
        date:'{{date(new Date(1970, 0, 1), new Date(),[DD-MM-YYYY])}}',
        identifiant: "4AAM26636",
        lastDayTrading: "50%",
        marketCapitalization: "13,44",
        objectType: "BUSINESS_GROUP",
        priceClosing: "100",
        twelveMHigh: "50",
        twelveMLow: "30"
      }
    ],
    ordering: "1W"
  }
]

实际上我收到此错误

"date": "<ReferenceError: DD is not defined>"

我也尝试过datef('YYYY-MM-DD');和其他组合

1 个答案:

答案 0 :(得分:4)

第三个参数应为字符串。而且日期应该用小写。

就像这样:

[
  '{{repeat(5, 7)}}',
  {
    equityPriceList: [
      {
        date:'{{date(new Date(1970, 0, 1), new Date(),"dd-MM-YYYY")}}',
        identifiant: "4AAM26636",
        lastDayTrading: "50%",
        marketCapitalization: "13,44",
        objectType: "BUSINESS_GROUP",
        priceClosing: "100",
        twelveMHigh: "50",
        twelveMLow: "30"
      }
    ],
    ordering: "1W"
  }
]