I have tried the Python croniter's get_prev() method to get the last scheduled time based on a cron string and current time.
When I tried it in windows machine it returned the value in 24 hour format. But when I tried the same code via AWS glue (possibly Linux) , it returned scheduled time in 12 hour format without AM/PM notation.
Is there any way to force the croniter to return time in 24 hour format always.
currentTime=datetime.now() print(currentTime) cron = croniter(cron_str, currentTime) lastCronScheduleTime=cron.get_prev(datetime) print(lastCronScheduleTime) 11 Answer
In your example, get_prev returns a datetime.datetime instance.
When a datetime is passed to print(), it is first converted to string by calling its __str__ method. The __str__ method calls isoformat() (see python docs).
In other words, the output from your example should be in ISO 8601 format, which always uses 24-hour notation.
My guess is you are seeing different hour values because your Windows and Linux machines use different timezones, and datetime.now() returns a naive datetime in system's default timezone.