Hi, I'm wondering if anyone can help me with this.
I've got an issue where I have to store a CSRF token in a user record custom field and a timestamp (in a datetime custom fieldfield) - then later check in a form if the token (part of the URL sent in an email) matches, and that it hasn't expired.
Problem is, when I generate a new Date() object on the backend, it contains the date in the timezone of the server - which is fine so far, but when I call nlapiSubmitField(<customer>, <id>, <tokenDateField>, new Date()) - it converts the date to our timezone and doesn't store timezone info in the field. So when I get the date back from the field when I validate the token, I get OUR timezone's datetime - but with the server's timezone attached to it, which causes it to be off by about 17 hours and makes it hard to do the comparison with the current time.
One might think that it's just a matter of subtracting 17 hours off it to do the maths, but it's not that simple due to daylight savings changes throughout the year.
Calculating timezone offsets in the backend using the standard JS Date object is not possible as far as I can tell as the toLocaleString() doesn't appear to be functional.
At the moment, I have a rather clumsy solution of doing the datetime offset calculation on the front-end where the Date object is fully implemented and passing it to my SuiteService in the backend to calculate the comparison correctly.
I'm wondering if there is something obvious and silly that I totally missed which would solve the problem. If anyone has any suggestions, would be much appreciated :)
Thanks.