Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Narrative Insights is Temporarily Unavailable due to an Infrastructure Issue. Learn how This Impacts Your Account and What to Expect While the Feature is Disabled.
Issue in the new Date object (Suitelet/SS)
Hello NetSuite Gurus,
I have a problem when creating new Date object, here is the example code and result:
string = '2019-12-07 19:02:32';
string = string.substring(0,10);
string = string.split('-');
var date = new Date(parseInt(string[0]), parseInt(string[1]) - 1, parseInt(string[2]), 0, 0, 0, 0);
response.write(date);
Result (OK):
Sat Dec 07 00:00:00 PST 2019
but when I do:
string = '2019-12-08 19:02:32';
string = string.substring(0,10);
string = string.split('-');
var date = new Date(parseInt(string[0]), parseInt(string[1]) - 1, parseInt(string[2]), 0, 0, 0, 0);
response.write(date);
The result is unexpected:
Wed Dec 31 16:00:00 PST 1969
Expected result:
Sun Dec 08 2019 00:00:00
What can cause this problem?
Tagged:
3