Displaying current date and time.

piyushkumar
Kilo Contributor

How make a popup (alert box) on load of a incident form which displays the current date and time.

1 ACCEPTED SOLUTION

In system Definition -> Client scripts



find_real_file.png


View solution in original post

8 REPLIES 8

vinothkumar
Tera Guru

Hi Piyush,



Create an Onload script and it will work.



var today = new Date();


var dd = today.getDate();


var mm = today.getMonth()+1; //January is 0!


var yyyy = today.getFullYear();


if(dd<10){


      dd='0'+dd;


}


if(mm<10){


      mm='0'+mm;


}


var today = dd+'/'+mm+'/'+yyyy;


alert(today);


Hi Vinoth,



Thanks for the code. As I am new to ServiceNow coding thing. Could you please help me where excatly I should write this code on my service now Dev environment.



BR// Piyush


gdd
Giga Expert

Hi,



You can put date in display business rule and use it in client side script for non catalog item stuff.


on catalog item you can get it using glideajax and script include.



-Girish