Does anyone know why the Date constructor (`new Da...
# suitescript
m
Does anyone know why the Date constructor (
new Date()
) doesn't seem to work with a string passed in, at least in server scripts, despite that being a part of the base JS specs? I'm getting an ISO date string back from an API and I was really hoping to not have to use a library or build a function just to parse something that standard JS should be able to do.
And an example of what I'm trying that's giving me
Invalid Date
in a Suitelet:
new Date('2022-07-28T13:06:15-05:00')
b
suitescript 2.0 is old enough to use a date constructor that was less well defined
it only accepts iso 8601 strings of the format "2022-08-12T202054.074Z"
m
Interesting. I new 2.0 had its limitations like that but I thought the flexibility in ISO formatting was old enough that it would be included. Good to know though, thanks for the insight. I just confirmed that the format I'm getting from the API works in 2.1 so when I make the switch I can streamline things a bit.