如何让时间显示为世界标准时间 #431

Open
opened 2025-03-29 12:48:06 +08:00 by YBB · 1 comment

如题,默认可读取的数据信息仅能读取当前时区的时间,参考了surftime后在编辑中的更新设置里填写了%z -800,或%Z GMT会分别显示中国标准时间 -800和中国标准时间 GMT 字样,只填写%Z会显示中国标准时间,有什么办法可以让输出的信息直接显示为世界标准时间的数字吗

如题,默认可读取的数据信息仅能读取当前时区的时间,参考了surftime后在编辑中的更新设置里填写了%z -800,或%Z GMT会分别显示中国标准时间 -800和中国标准时间 GMT 字样,只填写%Z会显示中国标准时间,有什么办法可以让输出的信息直接显示为世界标准时间的数字吗
Owner

strftime() 里面的 %z 就是打印当前时间是什么时区的。
想要显示世界时或者其他时区,目前只能用「自定义脚本」数据:

this.current = (new Date).toUTCString();
this.status = nvg.Value.Ready;

如果想格式化日期,可以这样写:

const now = new Date;
const utc = new Date(now.getUTCFullYear(),
                     now.getUTCMonth(),
                     now.getUTCDate(),
                     now.getUTCHours(),
                     now.getUTCMinutes(),
                     now.getUTCSeconds());

this.current = Qt.formatDateTime(utc, "yyyy-MM-dd hh:mm");
this.status = nvg.Value.Ready;
strftime() 里面的 `%z` 就是打印当前时间是什么时区的。 想要显示世界时或者其他时区,目前只能用「自定义脚本」数据: ``` this.current = (new Date).toUTCString(); this.status = nvg.Value.Ready; ``` 如果想格式化日期,可以这样写: ``` const now = new Date; const utc = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds()); this.current = Qt.formatDateTime(utc, "yyyy-MM-dd hh:mm"); this.status = nvg.Value.Ready; ```
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: core/sao-utils#431
No description provided.