Pull only the current time with Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2026 02:48 PM
Hello all,
I am working on configuring a record producer that will need to display certain variables depending on if it is during business hours or after hours. My thought was to use a client script to get the current time and hide/show variables depending on if its before or after the set time. I am able to get date and time, but wanted to know if there is a way to get only the current time to be captured.
Thanks for any assistance/guidance.
Joe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2026 07:29 PM
what type of variable is this?
you want current time in local time i.e. timezone of the logged in user or GMT time?
share some details and screenshots
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2026 08:24 PM
Hi @TacoJoe !!
Yes, you can get only the current time using standard client-side JavaScript.
Example in a Record Producer Catalog Client Script:
var now = new Date();
var hours = now.getHours(); // 0–23
var minutes = now.getMinutes(); // 0–59
You can then use this to show/hide variables:
if (hours >= 8 && hours < 17) {
g_form.setDisplay('after_hours_variable', false);
} else {
g_form.setDisplay('after_hours_variable', true);
}Note: This uses the end user's browser time. If you need true business-hours logic (holidays, time zones, daylight savings), best practice is to use a GlideSchedule in a client-callable Script Include and call it via GlideAjax.
Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.
Regards,
Vaishnavi
Associate Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2026 03:02 AM
Hi @TacoJoe ,
My recommendation will be to implement this via a combination of an onLoad Catalog client script and a GlideAjax.
Keep the "business hour" validation to server side using GlideDateTime APIs and just return true/false to the client side via GlideAjax.
Leverage this retured value to show or hide the variables/fields on the Record producer using g_form.setDisplay("field_name").

