SuiteScript 2.0将时区应用于字段

时间:2018-02-26 20:29:36

标签: netsuite suitescript2.0

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

提前致谢

1 个答案:

答案 0 :(得分:2)

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

使用示例如下:

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);
});

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