
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 06:33 AM
Hi Team,
I have a string 2022-03-22 06:03:51 PDT
I need to get the output as 2022-03-22 06:03 PDT
Please let me know how to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 06:51 AM
Hi,
it seems you want to remove seconds
simply do this
var str = '2022-03-22 06:03:51 PDT';
var time = str.split(' ');
var arr = time[1].toString().split(':');
var hour = arr[0];
var mins = arr[1];
var finalString = time[0] + ' ' + hour + ':' + mins + ' ' + time[2];
gs.info("Final string->" + finalString);
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 06:51 AM
Hi,
it seems you want to remove seconds
simply do this
var str = '2022-03-22 06:03:51 PDT';
var time = str.split(' ');
var arr = time[1].toString().split(':');
var hour = arr[0];
var mins = arr[1];
var finalString = time[0] + ' ' + hour + ':' + mins + ' ' + time[2];
gs.info("Final string->" + finalString);
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 10:24 AM
Hi Ankur,
Thanks.
But if I want to extract the same from sys_updated_on then how to do so?
The below script is not working.
Can you assist?
time = gr.sys_updated_on;
tme = time.split('');
arr = tme[1].toString().split(':');
hour = arr[0];
min = arr[1];
finaltime = tme[0] + ' ' + hour + ':' + min + ' ' + tme[2];
gs.print(finaltime);
BR,
Ankur