Options
- 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.
1 ACCEPTED SOLUTION
Options
- 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.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 10:09 AM
Hello @robinbkumar ,
Do you need to do this in a client side script or a server side script?
For client side you can use:
new Date().toGMTString();
For server side you can check some of the other answers.
Regards,
Robert