in reply to Re^2: MySQL datetime
in thread MySQL datetime

Just construct $dayssince like I have done in the sub (you don't need a sub) and then compare that to the threshold of 20 in your code, rather than $last_update.


🦛

Replies are listed 'Best First'.
Re^4: MySQL datetime
by joyfedl (Acolyte) on Jul 01, 2025 at 15:21 UTC

    Thanks so much, i got it working like the way you have advised me

    use strict; use warnings; use Time::Piece; use Time::Seconds qw/ ONE_DAY /; my $stamp = ('2025-06-30 14:40:26'); my $tp = Time::Piece->strptime (substr ($stamp, 0, 10), '%Y-%m-%d'); my $dayssince = (localtime() - $tp) / ONE_DAY; if ($dayssince < 20) { print "20 days havent passed\n"; } else { print "20 days have passed\n"; }