How to get Current hour in Scheduled job script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2023 12:07 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2023 12:18 AM
Hi @Akki1
Greetings!
I don't think we have glidedate API for hours and minutes.
refer below thread if it might be helpful.
Please mark my answer as helpful and correct if helped.
Kind Regards,
Ravi Chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2023 12:23 AM - edited ‎09-01-2023 10:17 AM
Hello @Akki1
you can use the GlideDateTime API to get the current hour and minute in a Scheduled Job script. Here's an example of how you can achieve this:
// Get the current date and time
var currentTime = new GlideDateTime();
// Get the current hour and minute
var currentHour = currentTime.getHourOfDayUTC();
var currentMinute = currentTime.getHourOfMinuteUTC();
// Log the values
gs.info("Current Hour: " + currentHour);
gs.info("Current Minute: " + currentMinute);
If my response successfully addresses your query, I kindly request you to consider marking it as the accepted solution. Doing so can be beneficial for others who might have a similar concern.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2023 12:26 AM
@Sonu Parab This is a ChatGPT reply 🙂
We don't have getHourOfDay() and getMinute() methods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2023 12:53 AM