use Time::Local; use POSIX qw(strftime); $lastlogin = lastlogin(2); sub lastlogin() { my $count = shift; mu $now_string = timelocal(localtime); $n_days_ago = (60*60*24*$count); $N_DAYS_EGO = $now_string - $n_days_ago; $N_DAYS_EGO = strftime("%Y-%m-%d %H:%M:%S",localtime($N_DAYS_EGO )); return $N_DAYS_EGO ; }