I'm working with dates in a restlet and I keep get...
# suitescript
w
I'm working with dates in a restlet and I keep getting an Invalid Date error. The restlet has this code
Copy code
var techStartTime = new Date('2019-06-12T18:00:00Z');
        log.debug({
            title: 'tech Start Time',
            details: techStartTime,
        });
It Errors out on the log.debug with Date is Invalid, but if I do it all manually in the console it works fine.
s
if using SS1, pass that date through
nlapiDateToString()
first
w
Using SS2 in the restlet. and the typeof equals string.
s
in SS2 you should be able to set the field value using a native Date, no?
since the model for dates is so different between SS1 and SS2 ( at least in theory) doing browser console tests in SS1 may not help much.
w
The Date is actually coming from a JSON, so I need to break it down to just the time so it will go into the TIME field. I'm looking at
format.format
now in the SS2 book now that you mentioned that there is a difference in how dates are handled in SS1 vs SS2.
b
I believe this is a rhino thing. Add milliseconds to your date
w
Milliseconds helped but the system that generates the date uses the ISO standard that has more digits so Netsuite still gave me an invalid date. I also found out that I was using a
setValue
when I needed a
setText
. In the end I figured out how to format the date time in the system that generates it to only pass what I needed.