Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Between Two Times??? Help!

by dakkar (Hermit)
on Mar 22, 2003 at 16:48 UTC ( #245172=note: print w/replies, xml ) Need Help??

in reply to Between Two Times??? Help!

Where does that strange date format come from? It's the first time I see a date with "day of the week" but without the year...


About your code: the two arrays are useless, since $days[$n]==$n for each $n, and the same holds for @Months. And keep in mind that @array[@indices] is an array slice, while $array[$index] is a single element. Search for "array slice" for more info.

Now, what do you really need to do? Do something if the current time is no later than 24 hour after a given date?

In this case, I'd do it this way:

use POSIX; # this module defines the function mktime $last='2/21/5/19:22:14'; # this is the timestamp of the user's last lo +gin $now=time; # the present ($sec,$min,$hr,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now-8 +6400); # a day ago ($mon2,$mday2,$wday2,$hr2,$min2,$sec2)=($last=~m|^(\d+)/(\d+)/(\d+)/(\ +d+):(\d+):(\d+)|) or die "Wrong timestamp: $last\n"; # extract values + from the timestamp, with a bit of checking $last_time=POSIX::mktime($sec2,$min2,$hr2,$mday2,$mon2,$year); # trans +form the timestamp into a unix-time (seconds since the epoch) unless (defined $last_time) {die "Wrong timestamp: $last\n"} # mktime +will return undef if the date is not valid print "In range" if ($now-$last_time)<86400; # if the difference is le +ss than a day...
        dakkar - Mobilis in mobile

Replies are listed 'Best First'.
Re: Re: Between Two Times??? Help!
by ACJavascript (Acolyte) on Mar 22, 2003 at 17:00 UTC
    HEY Dakkar,,, that posix module seems to work just great!!! I think this is just what i was looking for.. Thank you so very much... I can now continue... If something goes wrong I know were to come back LOL :D

    Thannks alot guys/gals!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://245172]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-05-18 13:44 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (71 votes). Check out past polls.