Playing with time in Perl

my $hour = (localtime(time))[2];

if ( $hour >= 22 && $hour <= 24 || $hour >= 0 && $hour <= 8 ) { print "Do something.n"; exit; }

Revisiting 10 Years Later! 2/17/21

my $hour = (gmtime(time))[2];

if ( $hour >= 5 && $hour < 13 ) { print "Closed\n"; } else { print "Open\n"; }

GMT PST
5 = 9 (9 PM)
6 = 10
7 = 11
8 = 12
9 = 13 (1 AM)
10 = 14 (2)
11 = 15 (3)
12 = 16 (4)
13 = 17 (5)
14 = 18 (6)
15 = 19 (7)

Leave a Reply

Your email address will not be published. Required fields are marked *