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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you cannot remove that.

Other way is to use DOM manipulation which is not recommended.

you cannot remove them, you can change the value with a client script or display business rule to change them to 00 for the seconds

Regards
Ankur

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

Okay thank you for your response, what is the logic to make it as 00 if we cant remove it

@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

hi ankur,

 

I can use same logic on BR also right?