【发布时间】:2019-02-11 21:53:34
【问题描述】:
我在 Watson 的 JSON 编辑器中执行简单的日期计算时遇到了一些困难。我有一个已知值,即日期:2018 年 7 月 27 日,我需要做的是根据当前日期计算并输出以月和日为单位的年龄。我试图根据表达式语言方法中给出的示例来解决这个问题,但我没有成功。
我需要做的是将 (new Date(2019, 2, 13)).getTime() 替换为 today() 之类的内容,以便在有人要求时实时计算月龄年龄,我尝试用 Today() 替换它,但它会导致错误...
{
"context": {
"days": "<? (((new Date(2019, 2, 13)).getTime() - (new Date(2018, 7, 29)).getTime()) / (1000 * 60 * 60 * 24)) / 30 ?>"
},
"output": {
"generic": [
{
"values": [
{
"text": "Abby is <? $days ?> months old."
},
{
"text": "The wonderful and beautiful Abbygale is <? $days ?>months old."
},
{
"text": "The incredibly smart and savvy Abby is <? $days ?> months old."
}
],
"response_type": "text",
"selection_policy": "sequential"
}
]
}
}
【问题讨论】: