How to convert date and time into another time zone in scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 01:25 AM
In below script include we are getting the location time zone and date of the location to be in office . Currently My Requirement is to convert the both location date(ld) and current datetime (nowDT) into location time zone i.e. getLOcationTimeZone . Both ld and now DT are in GMT time zone.
var getDate = Class.create();
getDate.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getDateInfo: function() {
var getLocation = current.variables.office_location.time_zone; // Get the LOcation Time Zone
var locationDate = this.getParameter('sysparm_user_sysId'); // Get the Date of the Location on which the user wants to be in office
var ld = new GlideDateTime(locationDate); // GMT Time Zone
var nowDT = new GlideDateTime(); //GMT Time Zone
var dur = GlideDateTime.subtract(nowDT,ld);
var duration = dur.getNumericValue();
var durationSeconds = (duration/1000);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2021 08:09 AM
There is an OOb script include that you can call rmConvertTimeZone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 04:56 AM
HI @Poorna7 ,
Hope you are doing great.
You canuse below script to conver to other time zone:
// Assuming 'originalDateTime' is the original date and time in the current time zone
var originalDateTime = new GlideDateTime();
// Set the desired time zone
originalDateTime.setTimeZone('Europe/London'); // you can pass user related dynamic time zone by looking throuh user record too.
// Retrieve the converted date and time in the new time zone
var convertedDateTime = originalDateTime.getDisplayValueInternal();
// Use the convertedDateTime variable as needed in your application
Regards,
Riya Verma