vendredi 15 juillet 2016

Random time between given hours using epoch time format


I would like to have a random time from given hours range, using epoch time format. For example, I have this:

start_time = int(time.time())
end_time = start_time + 5184000    # 60 days
random_time = random.randint(start_time, end_time)

And I want to get random time from 9am to 9pm only. What is the simplest and nicest way to achieve this in Python?


Aucun commentaire:

Enregistrer un commentaire