0

I want to set up some code that depending on the time of day (internal computer time i guess). It switches to do something else.

Heres in english:

y = 1 <br>
if 6:30am then<br>
  x = 1 + y<br>
if 7:00am then<br>
  x = 2 + y<br>
if any_other_time then<br>
  x = 0<br>

Here is what i have so far in my script.

import time<br>
clock = time.time()
y = 0
if clock < 6:30am
x = 2 + y

but i know this isn't right because time.time displays something different then 6:30am

Zypher
  • 37,405
  • 5
  • 53
  • 95

1 Answers1

0

IMHO i would use the datetime library

http://docs.python.org/library/datetime.html

eg.

>>> datetime.utcnow()   
datetime.datetime(2007, 12, 6, 15, 29, 43, 79060)

check this post too

https://stackoverflow.com/questions/1599060/how-can-i-get-an-accurate-utc-time-with-python

Arenstar
  • 3,602
  • 2
  • 25
  • 34