- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 07:57 AM
I am in GMT time zone and moved forward 1 hour to daylight savings time yesterday, so instance time is now UTC+1.
Using the following...
...(where starttimestring=2025-04-02 19:00:00) in Planned Start Date field in Create Change Request Record in a flow, set the field correctly to 02/04/2025 19:00:00 before daylight savings time change, but now sets the field to 02/04/2025 20:00:00. System log shows 'starttime: 2025-04-02 19:00:00'.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 08:51 AM - edited 04-01-2025 08:14 AM
Hello @Scott Eaglesham ,
It depends a bit on which time zone you mean when you say "local time". A fixed time zone (yours, GMT), or the local time zone of the user who triggers the flow?
In the first case you can use the following:
var starttimestring = '2025-04-02 19:00:00';
var starttime = new GlideDateTime(starttimestring);
starttime.setTimeZone('Europe/London');
starttime.subtract(starttime.getTZOffset());
grChangeRequest.start_date = starttime;
In the second case remove the "setTimeZone" part.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 08:51 AM - edited 04-01-2025 08:14 AM
Hello @Scott Eaglesham ,
It depends a bit on which time zone you mean when you say "local time". A fixed time zone (yours, GMT), or the local time zone of the user who triggers the flow?
In the first case you can use the following:
var starttimestring = '2025-04-02 19:00:00';
var starttime = new GlideDateTime(starttimestring);
starttime.setTimeZone('Europe/London');
starttime.subtract(starttime.getTZOffset());
grChangeRequest.start_date = starttime;
In the second case remove the "setTimeZone" part.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 10:04 PM
Do you know how setSchedule() works when DST comes into picture.
I am getting 1 hour less i.e. the schedule is 8 to 5 so it should give me 40 hours but this returns 39
var weekStartDate = new GlideDateTime(timeSheetStartDate); //week start date
gs.info('week start date' + weekStartDate);
var weekEndDate = new GlideDateTime(timeSheetStartDate);
weekEndDate.addDaysUTC(6); //week end date
gs.info(weekEndDate);
var durationCalculator = new DurationCalculator();
durationCalculator.setSchedule(userSchedule);
If I give UTC in that line as 2nd parameter to setSchedule() then it works fine
setSchedule(userSchedule);
We suspect that the problem lies with the setSchedule() method used in the calculations when Daylight comes into picture, as it is producing inconsistent results.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2025 09:18 AM
Hello @Scott Eaglesham
It's because the system time zone is set to US TIME ZONE. We also faced this. And this will happen because of DayLight Savings. One hour was gone, so now everything moved 1 hr ahead.
You need to change the system time zone to reflect this, but why is it needed ? That's how it works everywhere, is it sort of business requirement?
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 02:56 AM
Thanks for your responses. I managed to resolve by using isDST() to check if date/time uses daylight savings offset and, if so, setting to 1 hour earlier.