gpt4 book ai didi

javascript - 使用 Apps Script .toISOString() 方法转换时髦的日期时间

转载 作者:太空宇宙 更新时间:2023-11-04 16:27:11 25 4
gpt4 key购买 nike

我有一列采用以下时髦格式的日期时间:

2016-07-07 12:34:47 -0700

我知道我可以通过使用 JS/Apps 脚本中的 .toISOString() 函数将其转换为可用格式。

不要自以为是,但任何人都可以轻松实现这一壮举,帮助我迈出第一步,甚至为我指明可能可以做到这一点的已发布 Apps 脚本的方向吗?

非常感谢:)

最佳答案

使用区域设置约定以字符串形式返回 Date 对象:

var d = new Date();
var n = d.toLocaleDateString();

将今天的日期转换为可读的字符串:

var d = new Date();
var n = d.toDateString();

其他可能有用的功能:

.toUTCString()
.toString()

关于javascript - 使用 Apps Script .toISOString() 方法转换时髦的日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40120119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com