- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2020 02:36 AM
We have a date/time fields on change form now we dont want to display seconds in it? so any idea how it can be done?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2020 03:15 AM
sample onLoad client script as below
something like this
function onLoad(){
var value = g_form.getValue('opened_at');
var date = value.split(' ')[0];
var time = value.split(' ')[1].split(':');
var finalValue = date + ' ' + time[0] + ':' + time[1] + ':' + '00';
g_form.setValue('opened_at', finalValue);
}
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
‎10-21-2020 03:44 AM
Hi,
you can use same logic in display BR
instead of g_form use current object
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
‎02-17-2023 05:18 AM
I can also add that if you want the time for correct time zone you can use g_form.getDisplayValue("date_time_field") instead of g_form.getValue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2023 12:32 AM
Does this script works if the user change the date/time formats in their profiles ?