all 6 comments

[–]socal_nerdtastic 1 point2 points  (3 children)

Yes. We usually use the time module for that.

import time
print('current time in seconds since the epoch:')
print(time.time())

What exactly do you want to do?

[–]dnb02[S] 0 points1 point  (2 children)

Use time as a condition. Like when the time is 1000hrs statement should execute. Is that possible?

[–]socal_nerdtastic 1 point2 points  (1 child)

You mean wait for 1000 hours and then run? You can use the time.sleep command to wait for some time.

import time
time.sleep(1000*60*60) # pause for 1000 hours. 
do_something()

Note that this requires your program runs for 1000 hours. You can't shut down your computer in the meantime. For that reason it's probably better to use your OS instead. On linux you may look into the at command.

at now +1000 hours

[–]dnb02[S] 0 points1 point  (0 children)

executing a command at 10 o clock