Hi all,
I have searched and read through the docs within python but still cant find the command i need and hoping someone will be able to help.
I have the following line in my program to grab the current date/time:
localtime = time.asctime( time.localtime(time.time()) )
Im trying to get function to execute when it reaches a time i set within the program, similar to an alarm clock really.
what command do i need to enter to match the time but ignore the day/month/year?
Im not lazy, i did try finding out and trying different things but i find i learn easier if im shown lol
Thanks
A little help please
3 posts
- Posts: 20
- Joined: Sat Jun 16, 2012 1:34 pm
- Location: Derby
AshleyC wrote:Hi all,
I have searched and read through the docs within python but still cant find the command i need and hoping someone will be able to help.
I have the following line in my program to grab the current date/time:
localtime = time.asctime( time.localtime(time.time()) )
Im trying to get function to execute when it reaches a time i set within the program, similar to an alarm clock really.
what command do i need to enter to match the time but ignore the day/month/year?
Im not lazy, i did try finding out and trying different things but i find i learn easier if im shown lol
I would use the DateTime module.
- Code: Select all
from datetime import datetime
currentDateTime = datetime.now()
if currentDateTime.hour == 20 and currentDateTime.minute == 10:
do_something()
Of course if it is a small program that I want to run in its entirety I would use cron to schedule it.
- Posts: 265
- Joined: Tue Jan 10, 2012 11:05 am
That is just what i wanted, thanks for your help and time 
- Posts: 20
- Joined: Sat Jun 16, 2012 1:34 pm
- Location: Derby