- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2026 10:42 AM
My instance is in Australia/West Timezone, and I use below code... after record creation... frond end time and backend XML timings are different,, I want both frontend and backend start time should be 6:00:00 and 10:00:01
var daysToCreate = 60;
var gdt = new GlideDateTime();
for (var i = 1; i <= daysToCreate; i++) {
gdt.addDaysLocalTime(1);
var day = gdt.getDayOfWeekLocalTime();
if (day < 2 || day > 5) {
continue;
}
var dateStr = gdt.getLocalDate().toString();
createSlot(dateStr, "06:00:00", "10:00:00");
createSlot(dateStr, "10:00:01", "14:00:00");
}
function createSlot(date, startTime, endTime) {
var start = new GlideDateTime();
start.setDisplayValue(date + " " + startTime);
var end = new GlideDateTime();
end.setDisplayValue(date + " " + endTime);
var check = new GlideRecord('u_deploy');
check.addQuery('u_start_time', start);
check.setLimit(1);
check.query();
if (check.next()) {
return;
}
var slot = new GlideRecord('u_deploy');
slot.initialize();
slot.u_start_time = start;
slot.u_end_time = end;
slot.insert();
}
@Tanushree Maiti @Ankur Bawiskar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Sathwik1
As per following article:
Best Practices
Always verify the time zone abbreviation you are using (e.g., some time zones may require full names like "America/New_York").
Consider user preferences and system settings when converting times dynamically.
Store and process all timestamps in UTC to ensure consistency across global applications.
Refer this article - Converting Date/Time into Any Time Zone in ServiceNow
with sample code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago - last edited a month ago
Hi @Sathwik1 ,
The record is behaving as expected. In ServiceNow, Date/Time fields are stored in the database in UTC, while the form displays them in the user’s local time zone.
the values look different, they represent the same timestamp.
It may also help to look at functions such as setDisplayValueInternal() and getDisplayValueInternal().
Kind regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
in backend means in XML it always stored in UTC
But in UI it shows as per user's timezone
Please discuss with your customer what value they wish to set i.e. UTC or user's local timezone and accordingly update the code
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
@Sathwik1
I could see you closed the thread by marking response as correct.
So what was the issue and what worked for you?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Sathwik1
As per following article:
Best Practices
Always verify the time zone abbreviation you are using (e.g., some time zones may require full names like "America/New_York").
Consider user preferences and system settings when converting times dynamically.
Store and process all timestamps in UTC to ensure consistency across global applications.
Refer this article - Converting Date/Time into Any Time Zone in ServiceNow
with sample code
