Kendo UI 显示 UTC 至 AEST / AEDT
我有一个 Kendo UI 网格,它通过 AJAX 调用从 API 获取数据。 它有一个包含日期的列,日期来自后端,格式为 “2022-03-08T19:02:00”
。
这是我正在解析日期的网格列之一:
{
field: "createdDate",
title: "Created Date",
template:"<div class='createdDateTemplate'>#= kendo.toString(kendo.parseDate(createdDate)) #</div>",
width: 150
}
我想在所遵循的 AEST 或 AEDT 中显示此日期。这可以从模板本身实现吗?
编辑:
我知道 Kendo 自动以本地格式呈现日期时间,对我来说是这样的:
GMT+1000(澳大利亚东部标准时间)
但是是否可以在时间本身上添加+10来显示这个时间?
编辑:我正在尝试这个 template:"
但我收到此错误: 无法读取 null 的属性(读取“getFullYear”)
I have a Kendo UI grid that fetches data from API by AJAX call.
It has a column with date and the date is coming from backend in this format "2022-03-08T19:02:00"
.
This is one of the column of my grid where I am parsing the date :
{
field: "createdDate",
title: "Created Date",
template:"<div class='createdDateTemplate'>#= kendo.toString(kendo.parseDate(createdDate)) #</div>",
width: 150
}
I want to display this date in AEST or AEDT which ever is being followed . Is this possible from the template itself ?
EDIT :
I know that Kendo automatically renders date time in local format something like this for me:
GMT+1000 (Australian Eastern Standard Time)
But is it possible to display this time with +10 added to time itself ?
Edit: I am trying thistemplate:"<div class='createdDateTemplate'>#= kendo.toString(kendo.timezone.convert(kendo.parseDate(createdDate), 'Etc/UTC', 'Etc/GMT+10'), 'dd/MM/yyyy hh:mm tt') #</div>",
but I am getting this error:Cannot read properties of null (reading 'getFullYear')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您将 zzz 添加到 date 末尾,Kendo 会自动将日期转换为用户的本地时间,如下所示
yyyy-MM-ddTHH:mm:sszzz
。另一件事是,您说您的日期是 UTC,但它末尾没有 Z(零 utc 偏移量)。如果没有它,Kendo 不会添加偏移量,所以我建议添加它。
也许你可以尝试这样的事情:
Kendo automatically converts the dates to the user's local time if you add zzz to the end of date , like this
yyyy-MM-ddTHH:mm:sszzz
.One more thing , you say that your date is UTC but it doesn't have a Z (zero utc offset) at the end. Kendo won't add the offset without it , so I would recommend adding it.
Maybe you could try something like this:
是的,您可以按照您喜欢的方式显示日期。阅读 Kendo 日期解析文档。我建议后端以 ISO 格式发送它(例如 yyyy-MM-ddTHH:mm:ss)。这样在前端,您只需执行
parseDate
即可,无需其他参数。也许根据浏览器的语言设置,它会以 AEST 或 AEDT 格式显示。如果没有,那么您可以在日期上执行toString
。Yes, you can display the date however you like it. Read the Kendo Date Parsing documentation. I would suggest though that the back-end send it in ISO format (e.g.
yyyy-MM-ddTHH:mm:ss
). So that on the front-end, you can just doparseDate
without the need for additional parameters. Perhaps depending on the language setting of the browser it will be shown in AEST or AEDT format. If not, then you can dotoString
on the date.