- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2025 01:35 AM - edited 10-23-2025 01:36 AM
Hi there @is_12 , Here is the script it should work for all date and time formats regardless of any region.
Script -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gdt = new GlideDateTime();
gdt.setDisplayValue(newValue);
var dayOfWeek = getDayName(gdt);
var date3 = new GlideDateTime(gdt);
date3.addMonthsLocalTime(3);
var date6 = new GlideDateTime(gdt);
date6.addMonthsLocalTime(6);
var date12 = new GlideDateTime(gdt);
date12.addMonthsLocalTime(12);
g_form.setValue('day_of_week', dayOfWeek);
g_form.setValue('next_3_months', date3.getDisplayValue());
g_form.setValue('next_6_months', date6.getDisplayValue());
g_form.setValue('next_12_months', date12.getDisplayValue());
}
function getDayName(gdt) {
var jsDate = new Date(gdt.getNumericValue());
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
return days[jsDate.getDay()];
}
If this answer helps you in any way make sure to Mark this as accepted solution and give a thumbs up this will also benefit others as well.
Regards.
Saurabh V.