SuiteScript 1.0 to 2.1 reference
nlapiStringToDate in SuiteScript 2.1
In SuiteScript 2.1, nlapiStringToDate is replaced by format.parse / format.format from N/format. Converts between NetSuite date strings and Date objects.
Before and after
// SuiteScript 1.0
var d = nlapiStringToDate('1/31/2027');
var s = nlapiDateToString(new Date());// SuiteScript 2.1
define(['N/format'], (format) => {
const d = format.parse({ value: '1/31/2027', type: format.Type.DATE });
const s = format.format({ value: new Date(), type: format.Type.DATE });
});What to watch for
- Both respect the user's date format preference, as the 1.0 functions did.
- Do not build date strings with toString() or toLocaleDateString(); output differs between runtimes.
Related functions
- nlapiLoadFile becomes file.load
- nlapiCreateError becomes error.create
- nlapiLoadRecord becomes record.load
- All SuiteScript 1.0 functions
Find what still needs converting
Find every script that still calls nlapiStringToDate
SuiteMigrate lists the active 1.0 and 2.0 scripts in your NetSuite account, shows which ones you can read and which are locked, and drafts 2.1 conversions you review before deploying. Free for 5 conversions.
Examples are simplified. Test converted code in a NetSuite sandbox before deploying. SuiteMigrate is not affiliated with Oracle or NetSuite.