This topic covers the process of retrieving and managing date and time information in NetSuite using SuiteScript. Specifically, it addresses how to load the company’s timezone setting, format the current date and time according to that timezone, and then parse the formatted date back into a usable date object.
var companyInfo = config.load({
type: config.Type.COMPANY_INFORMATION
});
var TIMEZONE = companyInfo.getValue({
fieldId: 'timezone'
});
log.debug('TIMEZONE', TIMEZONE)
var zoneDate = format.format({
value: new Date(),
type: format.Type.DATETIME,
timezone: format.Timezone.TIMEZONE
});
var dateOBJ = format.parse({
value: zoneDate,
type: format.Type.DATETIME,
timezone: format.Timezone.TIMEZONE
});