toLocaleTimeString(); Time Zone

I have the following code in one of my monitors:
var timeStamp = new Date().toLocaleTimeString();

How does this derive what timezone I’m in? We’ve used this for a long time and before it used to convert the time to EST which is my timezone but now it’s putting it four hours ahead. I’m just running the API Test from the Atlanta , GA location in the settings. Thanks.

Hi @BigNStrauss - Insights automatically converts to the time if you provide WITH TIMEZONE on the end of your queries. Are you inserting on your timezone so that the query ignores any WITH TIMEZONE settings?

@stefan_garnham Sorry! I should have specified that this is a Synthetics Scripted Browser monitor, not Insights.

Hi @BigNStrauss,

The timezone for the local environment of all minions running a scripted monitor should be UTC, but if you could private message me a link to a monitor that has a history of the results you are reporting, I’m happy to look into this inconsistency you are observing.

Hi Michel,

I have a different issue. Since the timezone for scripted monitor is UTC. Is there a way that I can change the timezone during runtime of the script? because we have our application that has a validation to check the user’s timezone and will allow access only using HK timezone.

Hi @Jomar_Soco, I do not know of anyway to change the timezone of your scripted monitor mid run. You may need to duplicate the script and change the timezone to Asia/Hong_Kong using the WITH TIMEZONE on the end of your queries.

Hi, what is the solution to this. Did you find any? timezone does not change to the local time.

Hi @samhita.jude, I’m just going to tag @BigNStrauss to make sure they see it.

1 Like

Hi All,

My timezone is est and when I try to change the time to utc and vice versa, the script doesn’t accept it.
something like this : These are my trials but none coverts the time. Any help is much appreciated. Thanks!
let lastStart = new Date(new Date(lastRunStart.replace(“at”,","+new Date().getFullYear())));
let lastEnd1 = new Date() //.toLocaleTimeString(‘en-GB’, { timeZone: ‘UTC’ });
// console.log(lastEnd1.toLocaleTimeString());
// console.log(;
// console.log(lastEnd1.getTime());
// console.log(‘offset’+lastEnd1.getTimezoneOffset());

        //    console.log(lastEnd.getMonth());
        //    console.log(lastEnd.getTime());

        //    console.log('BeforeCondition'+lastEnd);
        //    console.log(lastStart.toUTCString()); 
        //    console.log(;