Check if date falls under schedule for specific timezone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2025 05:24 AM
Hi Community,
I need help with the code to check if date falls under schedule for specific timezone.
I am using isInSchedule() method, for some reason its not giving correct output, I have used this several times in past not sure why its giving me hard time now, may be i am missing some small point.
Tried various approaches:-
1.Basic approach to use getDisplayValue to get user's session timezone.
2. Another approach is to convert time zone and then give in isInSchedule method, for this i tried setTZ() and setTimeZone() both method, both are converting properly and getting output as per timezone only however schedule function is still not returning correct output.
Please let me know what i am missing here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 09:05 PM
Internally all date/time values are stored in GMT. so that could be the reason
check this link
How Glide schedule works with the time zone?
can you try to pass 2nd parameter to that function?
var gr = new GlideRecord("change_request");
gr.get("Change Sys_id");
var userDateFormat = gs.getSession().getUser().getDateTimeFormat();
var date = new GlideDateTime();
date.setDisplayValue(gr.start_date, userDateFormat);
var timeZone ="IST";
var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828', timeZone);
var inSchedule = schedule.isInSchedule(date);
gs.info(inSchedule);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 07:28 AM
@Ankur Bawiskar I tried this as well but no luck its still checking as per GMT time only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 07:29 AM
not very sure then.
try raising HI ticket.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2025 05:28 AM
Did you try setting GMT timezone?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2025 09:45 PM
Below support links could be helpful :
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0998732
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0787349
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.