Date/Time field - Have the time default to 23:59:59 instead of current time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 08:42 PM
I have a requirement from the business for one of the catalogs where the default value when clicking on the date/time calendar picker should be the current date and the time should be 23:59:59. Currently, it is setting the current time as the default time.
Can anyone help with this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 11:05 PM
Hi Nidhin,
Assuming you'd want to use an onChange client script, the following client script will set the field's ('due_date' in this example) value to be the date picked by the user + "23:59:59":
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '' || newValue.match(/23:59:59$/) != null) {
return;
}
g_form.setValue('due_date', newValue.replace(/[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/,"23:59:59"));
}
If you were instead working with server-side script, you could use the following:
var currentDate = new GlideDateTime().getDate();
var setDate = currentDate + " 23:59:59";
var setDateTime = new GlideDateTime();
setDateTime.setDisplayValue(setDate, "yyyy-d-M hh:mm:ss");
Give the client script a try and see if that meets your requirement.
Thanks,
-Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2016 11:05 PM
Hi Brian,
Thanks for the response. You have almost got there. When I use the client script, it displays 23:59:59 in the date/time field. However, I wanted the calendar pick to display the time by default. The use should have the opportunity to change it if required. Please see the screenshot. My requirement is to have the default values have the time displayed as 23:59:59 and not the current time.
Thanks
Nidhin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 09:46 AM
Hi Nidhin
I'm wondering if you ever found a way to solve your issue. I am currently searching a solution for the same requirement. I want to set the time in the choice field predefined to 08:00:00 instead of the current time, with the ability for the users to adjust the time to whatever they want.
Regards,
Simon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2018 07:10 AM
Simon I am attempting to do the same thing right now - did you find a solution?