SuiteScript 2.0 将时区应用于字段
SuiteScript 2.0 Apply Time Zone to field
我需要 "GET" 来自 "Record" 的日期字段并应用时区,在 1.0 中它只是使用 getDateTimeValue 并将时区作为第二个参数传递。在 2.0 中,您只有通用的 getValue 并且当将 TZ 作为第二个值传递或将其传递到选项包中时,它似乎只是忽略它。有人有想法吗?我在文档中找不到它。
提前致谢
在 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);
});
您可以将以上内容粘贴到新交易页面的控制台中,运行 以演示它的使用方法。
我需要 "GET" 来自 "Record" 的日期字段并应用时区,在 1.0 中它只是使用 getDateTimeValue 并将时区作为第二个参数传递。在 2.0 中,您只有通用的 getValue 并且当将 TZ 作为第二个值传递或将其传递到选项包中时,它似乎只是忽略它。有人有想法吗?我在文档中找不到它。
提前致谢
在 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);
});
您可以将以上内容粘贴到新交易页面的控制台中,运行 以演示它的使用方法。