netsuite is giving me date like this "2021-09-30T1...
# suitescript
r
netsuite is giving me date like this "2021-09-30T115131.147Z" and it self says
TypeError: tokenExpirationTime.getMonth is not a function
i even did format.format , nothing works edit: no method is working on string in netssuite, not even split
c
Share all of your code
n
try format.parse
r
netsuite datetime really sucks, so confusing.. error
tried everythinggggggg
parse, format
everything
its just not working
n
try format.parse(new Date(your date))
r
Copy code
var tokenExpirationTime = format.format({
      value: new Date(        
        new Date(date).setHours(date.getHours() + 6)
      ),
      type: format.Type.DATETIMETZ
    });
time is 12:41
even after format its ' 9/30/2021 124159 pm '
i have to just add 6 hrs and check
whether 6 hrs are up?
n
moment is your solution, I suppose.
momentJS
r
deprecated
c
No, it is not. It's essentially "finished". It works just fine
☝️ 2
s
You need to carefully read/understand the difference in the input/output in format.format and format.parse (or just use a date js lib, it doesn't have to be moment, lots of people just are already familiar with it).... format.format tries to return a string format.parse tries to return a date if the value you give these calls doesn't work, then it just gives it to you back without an error (this is main reason these are so annoying to work with) I personally never use N/format and only use moment if I need to manipulate dates
👍 1