gpt4 book ai didi

javascript - 应用程序脚本从 Date() 转换为可读的内容

转载 作者:行者123 更新时间:2023-12-02 21:47:48 27 4
gpt4 key购买 nike

好的,我有一张 Google 表格。

我正在编写应用程序脚本

此脚本在 GSuite 中循环提取有关 Chromebook 的数据,我可以使用 Date(device.autoUpdateExpiration) 转换 device.autoUpdateExpiration 的 native Long 结果> 如下:

do {
page = AdminDirectory.Chromeosdevices.list('my_customer', options);

page.chromeosdevices.forEach(function(device) {
devices.push([device.deviceId, device.serialNumber, device.orgUnitPath, device.annotatedUser, device.annotatedUser, device.annotatedLocation, device.annotatedAssetId, device.notes, device.model, Date(device.autoUpdateExpiration), device.macAddress, device.model]);
});
if (page.nextPageToken){
options.pageToken = page.nextPageToken;
}
} while (page.nextPageToken);

但是当脚本将 Chromebook 信息转储到单元格时,Date(device.autoUpdateExpiration) 的内容为:

2020 年 2 月 13 日星期四 15:10:35 GMT+0000(格林威治时间)

两个问题:

  1. 为什么这没有给我更新到期的实际日期?

  2. 如何将其转换为简单的 dd/mm/yyyy 输出?

最佳答案

您可以使用new Date(device.autoUpdateExpiration).toLocaleDateString()

关于javascript - 应用程序脚本从 Date() 转换为可读的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60211207/

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