I'm running a SuiteScript 2.0 script that is using the following javascript code to get the current date/time stamp factoring in time zone. However I have found that when this code runs that it does not always return the same format, on rare occasions it is returning an unexpected/unpredictable date/time formatted values. To test I ran the below code on a schedule and output results to the log, it can take several hours/days but eventually this code eventually returns unexpected values.
JavaScript code I am running:
var now = new Date();
var currentDateZoned = format.format( { value:now, type:format.Type.DATETIMETZ } );
Typically this consistently returns a date/time stamp with the following format:
8/21/2023 4:02:05 am
However on very rare occasions this code is returning date/time stamps formatted in seemingly random formats, a few examples of what I have seen are below:
08/18/2023 04:2:5 am
08/18/2023 04:2:9 am
8/18/2023 1:32:9 am
As you can see on these rare occasions the date/time format is returned in seemingly corrupt/unpredictable formats.
We're trying to determine if we are using format.format incorrectly, or if this may be a bug in format.format.
Thank you to anyone who can help us troubleshoot this.
Ryan