我有一个日期时间(UTC),我想将其更改为Oslo时区,并将其格式更改为包含+02:00。
输入是例如。"~t2016-06-09T11:14:21Z“。输出应为:"2016-06-09T13:14:21+02:00“
我尝试使用以下日期时间格式,但没有成功:
["datetime-format", "Europe/Oslo", "%Y-%m-%dT%H:%M:%S%z", "_S.InstallationDate"]根据文档,datetime-parse支持%z。datetime-format不支持吗?我如何解决我的问题?
发布于 2018-03-13 18:06:01
目前不支持此功能。一种可能的解决方法是使用固定偏移量(在示例中为2小时)格式化时间戳,以便您可以在字符串中硬编码偏移量:
{
"_id": "my-pipe",
"type": "pipe",
"source": {
"type": "embedded",
"entities": [{
"_id": "foo",
"InstallationDate": "~t2016-06-09T11:14:21Z"
}]
},
"transform": {
"type": "dtl",
"rules": {
"default": [
["comment", "shift by 2 hours (one hour in nanoseconds is 3.6e12)"],
["add", "formatted+0200",
["concat",
["datetime-format", "%Y-%m-%dT%H:%M:%S%z",
["datetime",
["+",
["*", 2, 3600000000000],
["integer", "_S.InstallationDate"]
]
]
], "+0200"]
]
]
}
}
}这为您提供了:
[
{
"_id": "foo",
"formatted+0200": "2016-06-09T13:14:21+0200"
}
]https://stackoverflow.com/questions/48785629
复制相似问题