Getting wrong answer as output from the function, but the same code is working fine on vs code



Please observe the above images, all I want is to get a present time using “new Date()” for that I am using below code to get a output.

const currentTime = new Date();
const hours = currentTime.getHours();
const minutes = currentTime.getMinutes();
const seconds = currentTime.getSeconds();
let time_time = ${hours}:${minutes}:${seconds}
console.log(time_time);

It is working fine on vs code but not in our platform functions. can anyone please help me on this!

@Eswar_Sai, In our platform, We use UTC Time. In VS Code, It will use the local time. Hence this difference.

Hence instead of using Direct Date Object, You can try using toLocaleString() in the function so that you can get common input in our Platform and as well in the VS Code Application.