How to convert IST to CET time zone ? please check.

jay97
Tera Contributor

I have below code I want to convert  "03/02/2023 08:00:00" IST  to  "2023-02-03 14:25:00" CET  ( Central Europe time . what code should I write?

 

 

var a="03/02/2023 08:00:00";
var gdt = new GlideDateTime(a);

 

output should in the CET time zone when even user give input to the a variable . please help.

5 REPLIES 5

skrzy001
Tera Contributor

Remember before you code, you should see see if you can rely on the system to do the work.  So before the code, you should check under the settings to convert the time zone.

Prasad Dhumal
Mega Sage
Mega Sage

Hello Jay,

You can use setTZ() method to set the timezone of the GlideDateTime object to CET

then use the getLocalDateTime() method to get the date and time in the desired format:

 

Something like this:

var a="03/02/2023 08:00:00";
var gdt = new GlideDateTime(a);
gdt.setTZ("CET");
var output = gdt.getLocalDateTime().toString("yyyy-MM-dd HH:mm:ss");

 

Background message, type:error, message: Function setTZ is not allowed in scope application.

Can you please check on it? 

Its Not a global application it seems, So try below code:

var a = "03/02/2023 08:00:00";
var gdt = new GlideDateTime(a);
var CETTime = gdt.getLocalTime().getValue();

This will return the date and time in the CET time zone, but it will not change the time zone of the original GlideDateTime object.