- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2024 01:09 AM
My query is how it is taking different todays date
Adjusted todayDate: 2024-06-13 14:00:00
and
Output:
logs created on 15-06-2024 at 17:41
Adjusted todayDate: 2024-06-14 14:00:00
please advice how to proceed to calculate todays date
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2024 05:03 AM
Hi @RamuN ,
The inconsistent Adjusted todayDate values in your logs seems related to time zone differences and the behavior of the GlideDateTime methods you are using.
The setDisplayValue method sets the date and time according to the user's time zone, which might be causing the discrepancy, you should use setValue which basically converts the time in UTC and then convert it based on users time zone.
You can use the below snippet for the same-
var gdt = new GlideDateTime();
var midnightUtc = new GlideDateTime(gdt.getDate().getByFormat('yyyy-MM-dd') + ' 00:00:00'); // UTC midnight
midnightUtc.setTZ(gdt.getTZ()); // Convert to user's time zone
gs.info("Adjusted todayDate: " + midnightUtc);
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2024 05:03 AM
Hi @RamuN ,
The inconsistent Adjusted todayDate values in your logs seems related to time zone differences and the behavior of the GlideDateTime methods you are using.
The setDisplayValue method sets the date and time according to the user's time zone, which might be causing the discrepancy, you should use setValue which basically converts the time in UTC and then convert it based on users time zone.
You can use the below snippet for the same-
var gdt = new GlideDateTime();
var midnightUtc = new GlideDateTime(gdt.getDate().getByFormat('yyyy-MM-dd') + ' 00:00:00'); // UTC midnight
midnightUtc.setTZ(gdt.getTZ()); // Convert to user's time zone
gs.info("Adjusted todayDate: " + midnightUtc);
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 03:57 AM
used below