Inconsistency in displaying the time zone using datetime.getDisplayValue()

Akansh
Tera Contributor

I have an email script which results a date and time after at certain duration. i see inconsistency across the instances with the same code the timezone is being print on the DEV instance, if the script is triggered on TEST instance it does not show the time zone in the output.
What can be the probable cause of this inconsistency?


please suggest.

thanks

Akansh. 

2 REPLIES 2

Anil Nemmikanti
Giga Guru

Hi, System returns the time zone according to instance time zone as per my understanding. Is the Dev and Test are in same time zone? Please share the script so that we can explore more?

below is the code

(
function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    // Add your code here
 //scTask is the glide record query
    if (scTask.next()) {
        var opened_at = new GlideDate();
       
        opened_at.setValue(scTask.u_pending_date_time);
        var schedRec = new GlideRecord('cmn_schedule');
        schedRec.get('name', '24 x 7');
        if (typeof GlideSchedule != 'undefined')
            var sched = new GlideSchedule(schedRec.sys_id);
        //Set the amount of time to add (in seconds)
       
       // var timeToAdd = 1 * 32400;
        var timeToAdd = 4 * 86400;
        durToAdd = new GlideDuration(timeToAdd * 1000);
        var newDateTime = sched.add(opened_at, durToAdd, '');
        newDateTime.setTimeZone('GMT');
        //Set the 'due_date' field to the new date/time

    }
    template.print(newDateTime.getDisplayValue());

})(current, template, email, email_action, event)