简体   繁体   中英

NetSuite RESTlet, Submitting Date/Time Timezone Issues

I have a RESTlet for creating new customer entities from form submissions on our website. 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). Then the RESTlet code needs to submit that timestamp as the correct date in Eastern Time.

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. I've been trying to pass the Olson value into setDateTimeValue, like the documentation and some other blog posts say.

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. The timeZone parameter is not the timezone to which the date should be converted to. It should be the timezone of the dateTime field. This API converts the value of dateTime to the USER'S TIMEZONE as set up in their NetSuite account.

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.

NetSuite servers are set to have PST Date/Time. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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