Re: How to see if a time is within two other times.



In article <1120074745.373483.169390@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Ninja67 <Ninja67@xxxxxxxxx> wrote:
>
> 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.

You could just use the built in localtime function like this:

my $current_hour = (localtime)[2];
if ($current_hour < 4) {
# Time is after midnight and before 4am
} else {
# Time is after 4am and before midnight
}

Read up on localtime(). It behaves differently depending on context.

--
James Taylor, London, UK PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.

.



Relevant Pages