Formats for Converting Dates to Local Date Strings

JavaScript supports several date formats and ways to create a date. After you create a date, you can convert it to a local date string. In SuiteScript 2.0, the default format for the converted date string is the long format. In SuiteScript 2.1, the default format for the converted date string is the short format.

Scenario

SuiteScript 2.0 Behavior

SuiteScript 2.1 Behavior

Create a date and log two different formats for that date:

                    var event = new Date(Date.UTC(2012, 12, 21, 12));
log.debug("date1 = ", event.toLocalDateString();
log.debug("date2 = ", event.toLocalDateString('de-De', { year: 'numeric', month: 'long', day: 'numeric' })); 

                  

The default format is the long format, and additional properties passed are ignored.

The output is:

  • date1 = December 21, 2012

  • date2 = December 21, 2012

The default format is the short format, and additional properties passed are ignored.

The output is:

  • date1 = 2012-12-21

  • date2 = 2012-12-21

Related Topics

General Notices