Greg
01/30/2025, 12:20 PMCeligo AI
01/30/2025, 12:20 PMAI generated answer (using internal Slack threads):****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** To convert a datetime field to your timezone using SuiteScript, you can use the
N/format
module. This module is designed to convert a Date object to and from strings using the current user's timezone.
Here is a sample code snippet:
javascript
var format = require('N/format');
var dateInUserTimezone = format.format({
value: new Date(),
type: format.Type.DATETIME
});
In this code, new Date()
is the date you want to convert. The format.format
function will convert the date to a string using the current user's timezone.
However, please note that all Date objects in SuiteScript are in Pacific Time by default. If you want to convert a date to a specific timezone other than the current user's timezone, you may need to manually calculate the timezone offset.
Also, if you are dealing with a custom field that only requires the time portion, it expects a Date object and it will take the time portion in Pacific Time. If you want it to respect the timezone set in the general preferences, you might want to consider changing the field to be a date/time field.Celigo AI
01/30/2025, 12:20 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833776414
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833291829
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829039
Celigo AI
01/30/2025, 12:20 PM