How to convert IST to CET time zone ? please check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 06:59 AM - edited 01-29-2023 07:22 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 08:59 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 09:18 AM
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");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 09:59 PM
Background message, type:error, message: Function setTZ is not allowed in scope application.
Can you please check on it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 07:56 AM
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.