ACJavascript has asked for the wisdom of the Perl Monks concerning the following question:
use POSIX; # this module defines the function mktime $last=$FORM{'userTime'}; # 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-$ +FORM{'timeControl'}); # a day ago ($mon2,$mday2,$wday2,$year2,$hr2,$min2,$sec2)=($last=~m|^(\d+)/(\d+)/( +\d+)/(\d+)/(\d+):(\d+):(\d+)|) or die "Wrong timestamp: $last\n"; # e +xtract values from the timestamp, with a bit of checking $year = $year + 1900; $last_time=POSIX::mktime($sec2,$min2,$hr2,$mday2,$mon2,$year2); # tran +s form the timestamp into a unix-time (seconds since the epoch) unless (defined $last_time) {die "Wrong timestamp2: $last\n$year, $yea +r2"} # mktime will return undef if the date is not valid
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with time 2
by MarkM (Curate) on Mar 26, 2003 at 05:25 UTC | |
|
Re: Help with time 2
by cfreak (Chaplain) on Mar 26, 2003 at 14:41 UTC | |
by Anonymous Monk on Mar 26, 2003 at 20:18 UTC |