Skip navigation.
Your source for Perl tips, howto's, faq and tutorials
( categories: )

To determine the day of week of a given date, use the function 'Day_of_Week' from 'Date::Calc' module.

Day_of_Week expects 3 parameters: year, month and day (in that order); it returns '1' for Monday, '2' for Tuesday and so on until '7' for Sunday.

To obtain the name of the day, use the function 'Day_of_Week_to_Text' (also from 'Date::Calc' module).

Day_of_Week_to_Text receives as a parameter the day of week and returns a string with the corresponding name.


use Date::Calc qw(:all);
$wday = Day_of_Week(2006,7,20);
print "The day of the week of 20th July, 2006 is: " . Day_of_Week_to_Text($wday) . "\n";