Gossamer Forum
Home : General : Perl Programming :

Day-of-the-year for specific date?

Quote Reply
Day-of-the-year for specific date?
How do i find day-of-the-year for specific date... Something like localtime(time) but this one for current date, what i want is for specific date like what is the day-of-the-year for Feb 2 1999?? Please help me with this one...
Quote Reply
Re: Day-of-the-year for specific date? In reply to
Hmm, you could do:

Code:
use Time::Local;
my $time = timelocal ($sec, $min, $hour, $day, $month, $year);
my @time = localtime($time);

timelocal() translates your date into seconds, then you throw that back into localtime() and you can get the day of the week out of it (I think it's $time[6], but double check).

Cheers,

Alex