H everyone ... me, back with more Date Time questi...
# suitescript
d
H everyone ... me, back with more Date Time questions (ARG!). I cannot get this right. I'm getting a UTC String
2023-11-10T04:23:00.000Z
that I'm need to set on a NetSuite field of type DateTime.
Copy code
const convertOption1 = (utcDateTimeString: string) => {
    const utcDateTime = new Date(utcDateTimeString);
    log.audit('convertOption1 - utcDateTime', utcDateTime.toISOString());

    const pstOffset = -8 * 60; // -8 hours * 60 minutes
    utcDateTime.setMinutes(utcDateTime.getMinutes() + pstOffset);
    return utcDateTime;
};
Currently, I'm simply converting it to PST, and setting the field.
b
your date was fine before you subtracted 8 hours from it
☝️ 1
d
What the?!?!
So, all this time, I could have simply taken the incoming UTC datetimestring, and just new Date(..) it, and save?
It must behave differently in non-system contexts (like client-scripts, etc). No?
b
The same, the Date constructor has always known how to convert that version of iso8601 into a Date
this 1