On Jan 20, Mallik said:

>How to calculate the Day of the week for a given date
>in PERL.
>
>Please provide me any code available that doesn't require
>any other modules to be installed.

You can do it with the standard module Time::Local.  You already have
this; it doesn't need to be installed.

  use Time::Local;

  my @days = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday );

  my ($d, $m, $y) = (1, 2, 2004);                 # Feb. 1, 2004
  my $when = timelocal(0,0,12, $d,$m-1,$y-1900);  # noon on Feb. 1, 2004
  my $dow = (localtime $when)[6];                 # day of week (0-6)
  my $day_name = $days[$dow];                     # name of day of week

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to