title: Python determine if time is between two hours in variables
body: <pre><code>settingsNightStart = settings[28]
  settingsNightStop = settings[29]
  
  
  if datetime.time(settingsNightStart) &lt;= datetime.time.now() &lt;= datetime.time(settingsNightStop):
      Night = 1
  </code></pre>
  
  <p>I have two variables coming from a database that users store there starting time and ending time in 24 hr format (0-23).  Is there a better way to store this setting from the user?</p>
  
  <p>I need to figure out how determine if the current time is between those two times.  Most of the time it's going to need to be determined over night where the users time will be starting at 8PM and ending at 7AM.  When I run the script I need to know if the current time is between those hours.  I don't know if datetime can work with what I'm trying to do?</p>
  
  <p>Thanks for any help.</p>