You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

date.toLocaleString JS function not working in OIC library

edited Jun 4, 2026 2:49PM in Integration 1 comment

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

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!