- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 08:25 AM
how to get current date time in this format "Mon, 07 Apr 2025 12:22:54 GMT" ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 09:45 AM
this background script worked for me
var gdt = new GlideDateTime();
var date = gdt.getDisplayValueInternal(); // Get the internal display value
// Format the date and time
var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var dayOfWeek = days[gdt.getDayOfWeekUTC()];
var day = gdt.getDayOfMonthUTC();
var month = months[gdt.getMonthUTC() - 1]; // getMonthUTC() returns 1-12, so subtract 1 for array index
var year = gdt.getYearUTC();
var time = gdt.getTime().toString().split(' ')[1]; // Extract time part
var formattedDate = dayOfWeek + ', ' + day + ' ' + month + ' ' + year + ' ' + time + ' GMT';
gs.info(formattedDate); // Output the formatted date
Output:
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
‎04-07-2025 08:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 09:45 AM
this background script worked for me
var gdt = new GlideDateTime();
var date = gdt.getDisplayValueInternal(); // Get the internal display value
// Format the date and time
var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var dayOfWeek = days[gdt.getDayOfWeekUTC()];
var day = gdt.getDayOfMonthUTC();
var month = months[gdt.getMonthUTC() - 1]; // getMonthUTC() returns 1-12, so subtract 1 for array index
var year = gdt.getYearUTC();
var time = gdt.getTime().toString().split(' ')[1]; // Extract time part
var formattedDate = dayOfWeek + ', ' + day + ' ' + month + ' ' + year + ' ' + time + ' GMT';
gs.info(formattedDate); // Output the formatted date
Output:
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
‎04-07-2025 08:42 PM
Hope you are doing good.
Did my reply answer your question?
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
‎04-07-2025 08:58 PM
I believe you should mark this response as correct so that it helps future members
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader