- 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-08-2018 01:39 PM
Hello
Please follow below given link, it might help.
https://community.servicenow.com/community?id=community_question&sys_id=ad8ccba5db9cdbc01dcaf3231f9619a6
Thanks
Ziaur Rahman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2018 12:07 PM
Thank you this pointed me in the right direction. The problem I'm having is now I am getting "null 08:00:00" in the field when it loads. I'd like it to default to the current date and 8:00am, so the time is correct but the date is not working for some reason.
Client Script onLoad:
function onLoad() {
//Type appropriate comment here, and begin script below
var ajax = new GlideAjax('MyDateTimeAjax');
ajax.addParam('sysparm_name', 'nowDateTime');
ajax.getXML(function () {
g_form.setValue('date_time_deployment', (ajax.getAnswer() + ' 08:00:00'));
});
}
Script Include: Client Callable
var MyDateTimeAjax = Class.create();
MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
nowDateTime: function () {
return gs.now();
}
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 08:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 08:52 AM