How to remove Seconds from Date/time fields?

Thousif S N2
Tera Contributor

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?

1 ACCEPTED SOLUTION

@Thousif S N 

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:

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Hi,

you can use same logic in display BR

instead of g_form use current object

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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.

 

Does this script works if the user change the date/time formats in their profiles ?