Reputation: 1232
I'm looking for the best way to determine whether the current time is between 9PM and 6AM, and perform the relevant action, depending on the boolean.
I'm not entirely sure on the best way of doing this though... I'm thinking I could maybe use epoch time (Time::Local) to get the time as it was at 9PM last night, and the time that it will be at 6AM the following day - but is this the best way of doing it or is there a better way?
Thanks
Upvotes: 0
Views: 2734
Reputation: 126722
This is all that is necessary
my $hour = (localtime)[2];
if ( $hour >= 21 or $hour < 6 ) { ... }
Upvotes: 2