The N/format module formats and parses data according to the user’s personal preferences set in NetSuite. It is essential for correctly handling dates, numbers, and currencies in SuiteScript β particularly when reading date fields or formatting values for display.
Formatting a Date
define(["N/format", "N/log"], (format, log) => {
const today = new Date();
const formatted = format.format({ value: today, type: format.Type.DATE });
log.debug("Formatted date", formatted); // e.g. "05/26/2026"
return {};
});
Parsing a Date String
const parsed = format.parse({ value: "05/26/2026", type: format.Type.DATE });
log.debug("Parsed date object", parsed.toString());
Common Format Types
| Type | Description |
|---|---|
format.Type.DATE | Format/parse dates |
format.Type.DATETIME | Format/parse date-time values |
format.Type.INTEGER | Format/parse integers |
format.Type.FLOAT | Format/parse decimal numbers |
format.Type.CURRENCY | Format/parse currency values |
format.Type.PERCENT | Format/parse percentage values |