Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

with the lastlogindate() i am getting timedifference

by perladdict (Chaplain)
on Aug 19, 2013 at 11:07 UTC ( #1050013=perlquestion: print w/ replies, xml ) Need Help??
perladdict has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I am using a subroutine to calculate the time difference which is used to calculate the users last login time. For example if the users ABCD lastlogin time is on 2013-08-15 HH:MM:SS,after that if ABCD is not logged in the system again it should display the same date and time as he last logged in. But it disaplying different time each time i run the script.
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 ; }

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.
Monks please suggest and guide me.
Thanks in advance.

Comment on with the lastlogindate() i am getting timedifference
Download Code
Re: with the lastlogindate() i am getting timedifference
by ww (Bishop) on Aug 19, 2013 at 11:23 UTC
    Perhaps you could give us a chance to help you ... by copy-pasting whatever the actual code you're actually executing... and a sample of your error messages.

    What you've posted so far is so full of typos and illogical code as to be almost incomprehensible.

    If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1050013]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2014-09-20 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (159 votes), past polls