Please Help With Simple Hour/Minute Code

Do you have a question on how to do something.
Ask in here.

Posts: 12
Joined: Wed Nov 11, 2015 3:30 pm
PostPosted: Sun Jul 24, 2016 10:15 pm
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
Posts: 1426
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City
PostPosted: Mon Jul 25, 2016 3:02 am
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

Posts: 12
Joined: Wed Nov 11, 2015 3:30 pm
PostPosted: Mon Jul 25, 2016 12:05 pm
Awesome. Thank you! I'll change it as soon as I get home.

Posts: 12
Joined: Wed Nov 11, 2015 3:30 pm
PostPosted: Mon Jul 25, 2016 9:52 pm
Thanks again Colin! That fixed everything.
User avatar
Posts: 1426
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City
PostPosted: Tue Jul 26, 2016 7:02 am
You're welcome!

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 3 guests