- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 05:01 AM
How to change the date format form 2018-07-20 07:37:35 to 20/07/2018 08:37:35.
I have created script include and client script for UTC end field. UTC end will display the GMT date and time automatically when we select the Incident End date and time. But here when I select the Incident date, UTC end date and time is displaying in different format. please can somebody help on how to display the date format in 20/07/2018 08:37:35.
Client Script:
var ga = new GlideAjax('PGIncidentAJAX');
ga.addParam('sysparm_name', 'getGMT');
ga.addParam('sysparm_date_time', newValue);
ga.getXML(processResponse);
function processResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_utc_end', answer);
}
Server Script:
var PGIncidentAJAX = Class.create();
PGIncidentAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGMT: function(){
var dt = this.getParameter('sysparm_date_time');
var gmt = new GlideDateTime();
// gmt.setStringParameter(dt.getByFormat("dd/MM/yyyy"));
gmt.setDisplayValue(dt);
return gmt;
},
type: 'PGIncidentAJAX'
});
Solved! Go to Solution.
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 11:13 AM
I test below in my Dev instance and worked.
var PGIncidentAJAX = Class.create();
PGIncidentAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGMT: function(){
var dt = this.getParameter('sysparm_date_time');
var gdt = new GlideDateTime();
gdt.setDisplayValue(dt);
var date = gdt.getValue().split(' ');
var dateonly = new GlideDate();
dateonly.setValue(date[0]);
var last = dateonly.getByFormat('dd/MM/yyyy') + " " + date[1];
return last;
},
type: 'PGIncidentAJAX'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 10:36 AM
Nope that doesnt work, it displays undefined

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 10:39 AM
I forgot to add var dt = this.getParameter('sysparm_date_time'); so make sure you have that before var gdt
var dt = this.getParameter('sysparm_date_time');
var gdt = new GlideDateTime();
gdt.setValue(dt.getDisplayValue());
var date = gdt.getValue().split(' ');
var dateonly = new GlideDate();
dateonly.setValue(date[0]);
var last = dateonly.getByFormat('dd/MM/yyyy') + " " + date[1];
return last;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 10:40 AM
i have Added that i just changed from the second line still it displayed undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 10:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018 10:41 AM