CharlesR1
Kilo Guru

Hi Tanumoy



We had a similar problem. We wanted to show specific time zones in our notifications for both our European and US offices. We had 'Proposed start' and 'Proposed End' times that we had to show in GMT, but also the needed to show CST and CET. We achieved this using a simple mail script as follows:




GMT and CET:




var cst_display = 'Undefined';


var bst_display = 'Undefined';



if (current.u_proposed_deploy_start) {


    var bst = new GlideDateTime(current.u_proposed_deploy_start);


    var b_tz = Packages.java.util.TimeZone.getTimeZone("Europe/London");


    bst.setTZ(b_tz);


    bst_display = bst.getDisplayValue();



    var cet = new GlideDateTime(current.u_proposed_deploy_start);


    var c_tz = Packages.java.util.TimeZone.getTimeZone("Europe/Paris");


    cet.setTZ(c_tz);


    cet_display = cet.getDisplayValue();


    }



  template.print(cet_display   + ' (' + bst_display + ')');



The text when called in the notification shows: '23-12-2015 10:51:01 CET (23-12-2015 09:51:01 GMT)'




GMT and CST:



This was a little trickier, as the date format for the US needs to be split in order to show MM/DD/YYYY - Script as follows:



var cst_display = 'Undefined';


var bst_display = 'Undefined';



if (current.u_proposed_deploy_start) {


    var bst = new GlideDateTime(current.u_proposed_deploy_start);


    var b_tz = Packages.java.util.TimeZone.getTimeZone("Europe/London");


    bst.setTZ(b_tz);


    bst_display = bst.getDisplayValue();



    var cst = new GlideDateTime(current.u_proposed_deploy_start);


    var c_tz = Packages.java.util.TimeZone.getTimeZone("Europe/Paris");


    cst.setTZ(c_tz);


    var cst_parts = cst.getDisplayValue().split(' ');


    var cst_date_parts = cst_parts[0].split('-'); // WARNING - assumes system date format is dd-mm-yyyy


    cst_display = cst_date_parts[1] + '/' + cst_date_parts[0] + '/' + cst_date_parts[2] + ' ' + cst_parts[1];


    if (cst_parts[2]) {


        cst_display += ' ' + cst_parts[2];


    }


}



  template.print(cst_display   + ' (' + bst_display + ')');




The text when called in the notification shows: '12-23-2015 10:51:01 CET (23-12-2015 09:51:01 GMT)'





Hope that's of some help!


Charles