Aaron McCausland
02/19/2025, 5:51 PMCeligo AI
02/19/2025, 5:51 PMAI generated answer (using internal Slack threads):The issue you're experiencing is due to the fact that JavaScript's
Date()
object uses the timezone of the environment where the code is running. In the case of server-side SuiteScript, this is UTC.
To fix this, you can use NetSuite's format
module to handle timezone conversions. The format
module provides a parse
method that can convert a string to a Date object, and a format
method that can convert a Date object to a string. Both methods accept an options object where you can specify the timezone.
Here's an example of how you can use it:
javascript
var format = require('N/format');
// Convert a string to a Date object in the current user's timezone
var dateObj = format.parse({
value: '1/1/2019 12:00 am',
type: format.Type.DATETIME,
timezone: format.Timezone.AMERICA_CHICAGO // Central Time
});
// Convert a Date object to a string in the current user's timezone
var dateString = format.format({
value: dateObj,
type: format.Type.DATETIME,
timezone: format.Timezone.AMERICA_CHICAGO // Central Time
});
This way, you don't have to worry about adjusting your code for daylight saving time, as the format
module will handle it for you.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
02/19/2025, 5:52 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.869929373
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.869019449
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.867252052
Celigo AI
02/19/2025, 5:52 PM