- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2018 12:35 PM
Hello - is there an easy way to set a default time on the date/time field variable? We have a need for the date picker to default to 8:00am EST when you open the calendar to pick the date/time.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 10:22 AM
I got it working using below script
function onLoad() {
var ajax = new GlideAjax('MyDateTimeAjax');
ajax.addParam('sysparm_name', 'nowDateTime');
ajax.getXML(function () {
var test = ajax.getXMLAnswer(function(answer){
var response = JSON.parse(answer);
//alert(response.datetime);
g_form.setValue('date_time_deployment', response.datetime);
});
});
}
var MyDateTimeAjax = Class.create();
MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
nowDateTime: function () {
var Date = new GlideDate();
var datetime = (Date + ' 08:00:00');
var response = {};
response.datetime = datetime;
return JSON.stringify(response);
},
type: 'MyDateTimeAjax'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 09:18 AM
Are you testing in desktop or Portal ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 09:23 AM
I'm in desktop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 09:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 09:29 AM
change your script includes to below
var now = GlideDate(); //Now Date
return now.getLocalDate();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 10:22 AM
I got it working using below script
function onLoad() {
var ajax = new GlideAjax('MyDateTimeAjax');
ajax.addParam('sysparm_name', 'nowDateTime');
ajax.getXML(function () {
var test = ajax.getXMLAnswer(function(answer){
var response = JSON.parse(answer);
//alert(response.datetime);
g_form.setValue('date_time_deployment', response.datetime);
});
});
}
var MyDateTimeAjax = Class.create();
MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
nowDateTime: function () {
var Date = new GlideDate();
var datetime = (Date + ' 08:00:00');
var response = {};
response.datetime = datetime;
return JSON.stringify(response);
},
type: 'MyDateTimeAjax'
});