date.toLocaleString JS function not working in OIC library
Hello,
I am using Library in OIC to create a function to convert UTC datetime to US datetime. The function works on browser but in OIC it returns UTC datetime (the same as in input to function). I have pasted the function below.
function convertUtcToTimezoneTest(utcString, timeZone) {
const date = new Date(utcString);
var convertedDateTimeStr = date.toLocaleString('en-US', {
timeZone: timeZone,
dateStyle: 'short',
timeStyle: 'short'
});
return convertedDateTimeStr;
}
Input: convertUtcToTimezoneTest('2026-06-04T06:59:59.000+00:00','America/Los_Angeles')
Expected output: '6/3/26, 11:59 PM'
Getting output: June 4, 2026 6:59:59 AM UTC
Tagged:
0