I ran into a bug with nlapiDateToString({Date}, 'time') (case# 733146) and needed to workaround it. I had some other date-related work to do tonight so I wrapped it up into a class.
Figured I would share it here if anyone is interested. It's not very deep, might have bugs and was created to fit my needs.
/** * @class DateUtils * @Description Duh, it's a utility class for working with dates?? */ function DateUtils(){} /** * Returns a new Date object that has the TimeZone component removed. * @return {Date} The new Date object */ DateUtils.GetGMTDate = function DateUtils_GetGMTDate() { var d = new Date(); var timeZoneOffset = d.getTimezoneOffset() * 60 * 1000; return new Date(d.getTime() - timeZoneOffset); } /** * Returns a Date object representing the date this task is due taking into * consideration the weekend and counting only business days as valid days. * @return {Date} The new date object * @param {Number} daysInFuture - Number of days in the future * @param {Boolean} weekdaysOnly - only add weekdays. If true and today is * Friday and you want to add 2 days it will result in Tuesday, not Sunday. */ DateUtils.GetDatePlusDays = function DateUtils_GetDatePlusDays(daysInFuture, weekdaysOnly) { if(weekdaysOnly == null) weekdaysOnly = false; if(daysInFuture == null || daysInFuture == undefined) { throw nlapiCreateError('REQUIRED_PARAMETER_MISSING', 'GetDatePlusDays() requires valid number of days', false); } // helper function that will return the date the task is due. It will // take into consideration the weekends and set the due date based on // weekdays only. var d = new Date(); var dayNum = d.getDay(); // If current day of the week + days to wait is a weekend, add 2 days if(weekdaysOnly && dayNum + daysInFuture > 5) { daysInFuture += 2; } d.setDate(d.getDate() + daysInFuture); return d; } /** * Constructs a new Date object from the supplied milliseconds * since midnight, January 1st 1970 * @param {Number} timeMs The number of milliseconds since midnight 01/01/1970 * @param {Boolean} useGMT if true the date will be based on GMT, else local time * @return {Date} the new Date object */ DateUtils.CreateDateFromMilliseconds = function DateUtils_CreateDateFromMilliseconds(timeMs, useGMT) { Guard.NotNullOrEmpty(timeMs, 'a valid time value must be supplied'); useGMT = useGMT || false; var d = (useGMT) ? DateUtils.GetGMTDate() : new Date(); d.setTime(timeMs); return d; } /** * nlapiDateToString({Date}, 'time') has a bug and returns the date, not the time. * This is a temp replacement until they solve the problem. * The seconds code is commented out because the TimeOfDate field has a parsing * bug that will fail on a second component, drop the second data and set the AM/PM * to am. Nice. * @return {String} the time representation of the date * @param {Date} date The date to convert */ DateUtils.MyDateToTimeString = function DateUtils_MyDateToTimeString(date) { var curr_hour = date.getHours(); var curr_min = date.getMinutes(); // var curr_sec = date.getSeconds(); var a_p = (curr_hour < 12) ? 'am' : 'pm'; if (curr_hour == 0) { curr_hour = 12; } if (curr_hour > 12) { curr_hour -= 12; } return [curr_hour, ':', curr_min, /*':', curr_sec, */' ', a_p].join(''); } If you find a bug let me know!