in reply to Comparing a string value's time with the computers time
use strict; use warnings; use POSIX qw{ strftime }; my $db_time = "7:05"; my $current_hour = strftime( "%H", localtime() ); my $current_minute = strftime( "%M", localtime() ); my ($db_hour, $db_minute) = split( /:/, $db_time ); if ( $db_hour > $current_hour ) { print "It is still open.\n"; } elsif ( $db_hour < $current_hour ) { print "It is closed already.\n"; } elsif ( $db_minute > $current_minute ) { print "It is still open\n"; } elsif ( $db_minute < $current_minute ) { print "It is closed already.\n"; } else { print "Hurry... It is closing RIGHT NOW!!!"; }
-- -- GhodmodeBlessed is he who has found his work; let him ask no other blessedness.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing a string value's time with the computers time
by crashtest (Curate) on Aug 03, 2006 at 05:30 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |