Re: How to see if a time is within two other times.
- From: "A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Jun 2005 20:51:48 GMT
"A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx> wrote in
news:Xns9684A8284206Dasu1cornelledu@xxxxxxxxx:
> "Ninja67" <Ninja67@xxxxxxxxx> wrote in
> news:1120074745.373483.169390@xxxxxxxxxxxxxxxxxxxxxxxxxxxx:
>
>> I need to modify a script in such a way that it checks the current
>> time (according to the server) to determine if the current time falls
>> within a particular time span such as midnight to 4:00 am.
>
> Time::Local can help:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use Time::Local;
>
> # 2005/06/29 16:00:00
> my $start = timelocal(0, 0, 16, 29, 5, 2005);
> my $end = $start + (4 * 60 * 60);
>
>
> if($start <= time and time <= $end) {
Actually, it is useless to call time twice (not likely to matter too much
given the resolution is in seconds, but still).
Sinan
--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
.
- References:
- How to see if a time is within two other times.
- From: Ninja67
- Re: How to see if a time is within two other times.
- From: A. Sinan Unur
- How to see if a time is within two other times.
- Prev by Date: Re: How to redirect to webpage using perl?
- Next by Date: re:UTF-8 to named character entities
- Previous by thread: Re: How to see if a time is within two other times.
- Next by thread: FAQ 3.2 How can I use Perl interactively?
- Index(es):
Relevant Pages
|