【问题标题】:How to get values of date & time fields as millisecs from netsuite suitescript 2.0如何从 netsuite suitescript 2.0 以毫秒为单位获取日期和时间字段的值
【发布时间】:2019-02-13 15:43:25
【问题描述】:

在 Suitescript 2.0 中,我可以通过 id 获取记录。

RESTlet:

    var response = record.load({
        type: resourceType,
        id: context.recordId
    });

回复:

{
   ...
   "starttime": "6:00 pm",
   "startdate": "13 FEBRUARY, 2019"
   ...
}

如何使用 suitescript 2.0 在 Netsuite 中以毫秒为单位获取所有日期和时间值?

【问题讨论】:

    标签: netsuite suitescript suitescript2.0


    【解决方案1】:

    NetSuite 有 2 种日期字段,datedateTime

    日期字段不包含时间详细信息,因此您无法从这些字段(如 trandate 等)中获取时间。而如果您在 dateTime 字段上使用 getValue,NetSuite 返回一个日期对象,您可以使用 toISOString 或任何其他方法Date 班级。

    【讨论】:

    • 实际上,我们正在使用 getValue() 并且它没有返回具有正确时区的日期对象。如果用户/帐户时区为 IST,则返回的日期为 PST。 format.format(), format.parse() 都没有考虑我们正在传递的时区(IST)。
    • AFAIK,netsuite 将 dateTime 保存为服务器格式(即 netsuite 数据中心),所以你不能在那里做太多事情。但是要将 dateTime 转换为正确/所需的时区,您可以使用像 moment 这样的 js 库。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-19
    • 2022-11-27
    • 2011-01-21
    • 1970-01-01
    • 2011-05-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多