My example was: How to compare dates using perl?
...
# $ARG1 is specified by the user for example "10" min
my $difftime=$ARG1;
# -- Get date ---------------------------------------------------------------------
#Stores current date and time - $time min
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time() - (60*$difftime));
$year += 1900;
#parse date format to '22.10.2021 00:00:00' -----------------------------------------------------
my $act_date="$mday.$mon.$year $hour:$min:$sec";
...
My first problem is $hour and $mon are one to low why?
My second problem is the time is with one digit "8:4:34" and not with two digits "08:04:34". Is that a problem for a date comparison?
...
#compare date
# date example for $sql_value is 06.10.2021 09:38:27
my $date_to_compare=$sql_value;
if ($act_date <= $date_to_compare)
{
print "the current date is smaller";
}
else
{
print "the current date is greater";
}
...
I get only "the current date is smaller" Why?
Additionally how can i get the time different in minutes?
thanks