0

我需要从“记录”中“获取”一个日期字段并应用一个时区,在 1.0 中它只是使用 getDateTimeValue 并将时区作为第二个参数传递。在 2.0 中,您只有通用 getValue 并且当将 TZ 作为第二个值传递或将其传递到选项包中时,它似乎只是忽略它。有人有想法吗?我在文档中找不到它。

提前致谢

4

1 回答 1

2

在 SuiteScript 2.0 中,您需要使用N/format 模块将时区应用于原始日期。

使用示例如下:

require(['N/format'], function () {

    var format = require('N/format');
    var now = new Date();
    console.log(now);
    var nyTime = format.format({
        value:now,
        type:format.Type.DATETIME,
        timezone:format.Timezone.AMERICA_NEWYORK
    });
    console.log('NY time is ' + nyTime);
    var gmt = format.format({
        value:now,
        type:format.Type.DATETIME,
        timezone:format.Timezone.GMT
    });

console.log('London time is ' + gmt);
});

您可以将以上内容粘贴到新交易页面的控制台中并运行它以演示它的使用方式。

于 2018-02-26T20:55:16.570 回答