perladdict has asked for the wisdom of the Perl Monks concerning the following question:
If i call the subroutine with with some numeric values the date it is returinging is correct, but the time field is varying. For Ex if user has terminated on 10-04-2013:HH:MM:SS and he last logged is on 8-04-2013 than it should display the same date and time if we run the script even today, but i am getting the time field different than this, it leading to wrong login information.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 ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: with the lastlogindate() i am getting timedifference
by ww (Archbishop) on Aug 19, 2013 at 11:23 UTC |