Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to Set Time for scheduled job based on time_zone in cmn_location table.

VikramM1
Tera Contributor

How to get time based on the display value of timezone field in cmn_location table.

 

I am running one schedule job periodically and set time zone based on IST with below code. But i want to set timezone based on Timezone field in cmn_location table. Can someone provide me the code to set time based on timezone available in timezone field.

 

var gdt = new GlideDateTime();
        var gdt1 = new GlideDateTime();
        var tz = Packages.java.util.TimeZone.getTimeZone("IST"); // sets to IST
        gdt1.setTZ(tz);
        gdt1.setValue(gdt);
        var time= gdt1.getDisplayValueInternal(); // Use getDisplayValueInternal() for 24-hour format
        time= new GlideDateTime(start);
1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron
5 REPLIES 5

Hi @VikramM1 

 

Please refer below posts :

https://www.servicenow.com/community/itsm-forum/how-to-get-the-week-number-and-month-name-and-year-u...

https://www.servicenow.com/community/developer-forum/calculating-month-and-year/m-p/2132601/page/2

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.