Please Help With Simple Hour/Minute Code

Do you have a question on how to do something.
Ask in here.
Post Reply
tmoore103
Posts: 12
Joined: Wed Nov 11, 2015 3:30 pm

Please Help With Simple Hour/Minute Code

Post by tmoore103 »

Hi All,

I'm very bad at coding and have just been getting by coping sections of other users PDEs that I think will work for me. Can someone show me how to use minutes with the hour or tell me if this is even possible. I've tried searching on here and Google but I haven't found a solution. I would like to perform a task between 7:15 and 7:30 for example. This is what I currently have.

Code: Select all

 if (hour(t)>=1715 && hour(t)<1730)
It compiles but doesn't seem to work correctly. I would like to keep it close to the hour format so I don't have to redo my entire sketch but I can make changes if necessary. ANY input or feedback will be greatly appreciated.

Thanks,
Tori
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Please Help With Simple Hour/Minute Code

Post by cosmith71 »

hour() is going to return an integer between 0 and 23. You want something like this to get the minutes in there.

Code: Select all

if ((hour()==17 && minute() >= 15) && (hour()==17 && minute() <30))
--Colin
tmoore103
Posts: 12
Joined: Wed Nov 11, 2015 3:30 pm

Re: Please Help With Simple Hour/Minute Code

Post by tmoore103 »

Awesome. Thank you! I'll change it as soon as I get home.
tmoore103
Posts: 12
Joined: Wed Nov 11, 2015 3:30 pm

Re: Please Help With Simple Hour/Minute Code

Post by tmoore103 »

Thanks again Colin! That fixed everything.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Please Help With Simple Hour/Minute Code

Post by cosmith71 »

You're welcome!
Post Reply