Time conversion to 24hr format

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

I was asked to write a script to convert CST time to GMT time. I developed that successfully but now i am asked to convert 12 hour format to 24 hour format in same script. Can you please suggest what changes i can do to achieve this in below script.

var tz = Packages.java.util.TimeZone.getTimeZone("GMT");

var sd = new GlideDateTime();
sd.setTZ(tz);
sd.setValue(current.start_date);
variable.inputs.planned_start_date = sd.getDisplayValue().toString();

var ed = new GlideDateTime();
ed.setTZ(tz);
ed.setValue(current.end_date);
variable.inputs.planned_end_date = ed.getDisplayValue().toString();

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023
20 REPLIES 20

Vivektietsood
Tera Guru
Tera Guru

Hi @JagjeetSingh can you pls accept the solution if you found it helpful so that it helps others in the community also ? Thanks