Page 1 of 1

Please Help With Simple Hour/Minute Code

Posted: Sun Jul 24, 2016 10:15 pm
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

Re: Please Help With Simple Hour/Minute Code

Posted: Mon Jul 25, 2016 3:02 am
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

Re: Please Help With Simple Hour/Minute Code

Posted: Mon Jul 25, 2016 12:05 pm
by tmoore103
Awesome. Thank you! I'll change it as soon as I get home.

Re: Please Help With Simple Hour/Minute Code

Posted: Mon Jul 25, 2016 9:52 pm
by tmoore103
Thanks again Colin! That fixed everything.

Re: Please Help With Simple Hour/Minute Code

Posted: Tue Jul 26, 2016 7:02 am
by cosmith71
You're welcome!