We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to get Current hour in Scheduled job script?

Akki1
Tera Contributor

Hi,

I'm trying to get the current hour and minute in Scheduled job script but I don't know how to get it . Can someone help here?

5 REPLIES 5

SANDEEP28
Mega Sage

@Akki1 You can try javascript date object

 

var currentTime = new Date();

 

var year = currentTime.getFullYear();

 

var month = currentTime.getMonth() + 1;

 

var day = currentTime.getDate();

 

var hours = currentTime.getHours();

 

var minutes = currentTime.getMinutes();

 

var seconds = currentTime.getSeconds();



gs.print('currentTime :' + currentTime);

 

gs.print('hours :' + hours);

 

gs.print('minutes :' + minutes);

 

gs.print('seconds :' + seconds);

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!