I only want to run a piece of code if the time is between specific minutes in an hour but I can't figure out how to get the hour number in Python.
The equivalent code in PHP is:
if (intval(date('i', time())) > 15 && intval(date('i', time())) < 32) {
// any time from hour:16 to hour:33, inclusive
} else {
// any time until hour:15 or from hour:32
}
In Python it would be something like this:
import time
from datetime import date
if date.fromtimestamp(time.time()):
run_my_code()
else:
print('Not running my code')
I'd typically use cron but this is running inside a Lambda and I want to make absolutely sure this code does NOT get run all the time.