简体   繁体   English

NetSuite RESTlet,提交日期/时间时区问题

[英]NetSuite RESTlet, Submitting Date/Time Timezone Issues

I have a RESTlet for creating new customer entities from form submissions on our website.我有一个 RESTlet,用于从我们网站上的表单提交中创建新的客户实体。 I'm trying to save three values in custom Date/Time entity fields that I added to the customer record.我正在尝试在添加到客户记录的自定义日期/时间实体字段中保存三个值。 The service accepts the dates as timestamp integers (eg 1421434991537).该服务接受日期作为时间戳整数(例如 1421434991537)。 Then the RESTlet code needs to submit that timestamp as the correct date in Eastern Time.然后 RESTlet 代码需要将该时间戳作为东部时间的正确日期提交。

I've been reading up on the issues with NetSuite date/times, where when I create the date object using "new Date(myIntVal)", it creates it in Pacific Time.我一直在阅读有关 NetSuite 日期/时间的问题,当我使用“new Date(myIntVal)”创建日期对象时,它会在太平洋时间创建它。 I've been trying to pass the Olson value into setDateTimeValue, like the documentation and some other blog posts say.我一直在尝试将 Olson 值传递给 setDateTimeValue,就像文档和其他一些博客文章所说的那样。

I need these values saved as Eastern Time, but no matter what I do, the time is ALWAYS submitted in Pacific Time.我需要将这些值保存为东部时间,但无论我做什么,时间总是以太平洋时间提交。 What am I missing?我错过了什么?

 // firstVisit, previousVisit, and currentVisit are all the timestamp int values. var firstVisitDate = nlapiDateToString(new Date(firstVisit), 'datetimetz'); var previousVisitDate = nlapiDateToString(new Date(previousVisit), 'datetimetz'); var currentVisitDate = nlapiDateToString(new Date(currentVisit), 'datetimetz'); leadRecord.setDateTimeValue(FIELD_NAME_WEB_FIRST_VISIT, firstVisitDate, 14); leadRecord.setDateTimeValue(FIELD_NAME_WEB_PREVIOUS_VISIT, previousVisitDate, 14); leadRecord.setDateTimeValue(FIELD_NAME_WEB_CURRENT_VISIT, currentVisitDate, 14);

The nlapiSetDateTimeValue API has the following parameters fieldId, dateTime and timeZone. nlapiSetDateTimeValue API 具有以下参数 fieldId、dateTime 和 timeZone。 The timeZone parameter is not the timezone to which the date should be converted to. timeZone 参数不是日期应转换到的时区。 It should be the timezone of the dateTime field.它应该是 dateTime 字段的时区。 This API converts the value of dateTime to the USER'S TIMEZONE as set up in their NetSuite account.此 API 将 dateTime 的值转换为在其 NetSuite 帐户中设置的用户时区

So make sure that the user running the RESTlet has their timezone set to Eastern then pass the Olson value of Pacific in your API call.因此,请确保运行 RESTlet 的用户将他们的时区设置为 Eastern,然后在您的 API 调用中传递 Pacific 的 Olson 值。

NetSuite servers are set to have PST Date/Time. NetSuite 服务器设置为具有 PST 日期/时间。 If your date/time is on EST, convert it first to PST before updating the record and if your are pulling out the date/time from NetSuite convert it to EST then.如果您的日期/时间在 EST 上,请先将其转换为 PST,然后再更新记录,如果您要从 NetSuite 中提取日期/时间,则将其转换为 EST。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM