Format Time of Day as a String

The following sample formats the time of day as a string using format.format(options).

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

          /**
 * @NApiVersion 2.x
 */

require(['N/format'], 
    function(format){
         function formatTimeOfDay() {
              // Assume the time format is hh:mm (24 hours) 
              var now = new Date(); // Say it's 7:01PM right now.
              return format.format({value: now, type: format.Type.TIMEOFDAY})  
              }
        var formattedTime = formatTimeOfDay(); // "19:01" -- a string 
  }); 

        

General Notices