【问题标题】:Json data generator date and time only仅 Json 数据生成器日期和时间
【发布时间】:2016-06-06 08:26:03
【问题描述】:

我正在尝试使用http://beta.json-generator.com/ 生成一些 Json 数据,但我不知道如何仅生成日期和时间(而不是日期时间)

例如下面的代码:

[
{
'repeat(5, 10)': {
  _id: '{{objectId()}}',
  date: '{{date()}}',
  date_only: '{{date()}}',  //how can I show here date only
  time_only: '{{date()}}',  //how can I show here time only
  user: {
    first: '{{firstName()}}',
    last: '{{surname()}}'
  },
  phone: '+1 {{phone()}}'
}
}
]

关于如何对 date_only 和 time_only 行进行编码以截断日期时间的任何想法?

另外,可以格式化 {date}。例如,而不是:

"Sat Mar 31 1990 21:01:10 GMT+0000 (UTC)"

...类似于:

"2010-12-13 21:01:10 GMT"

谢谢

【问题讨论】:

    标签: json date datetime code-generation


    【解决方案1】:

    【讨论】:

    • 我尝试的时候报错,例如:date_only: '{{Date(1995, 11, 17)}}', /Error: TypeError: undefined is not a function
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 2013-02-05
    • 1970-01-01
    • 2015-08-25
    相关资源
    最近更新 更多