Get the last day of a month

This example program demonstrates how to get the number of days in a month using Date::Calc.

use warnings;
use strict;
use Date::Calc qw/Days_in_Month Month_to_Text/;
my $month = 2;
my $year = 2016;
print "There are ", Days_in_Month ($year, $month), " days in ", Month_to_Text ($month), " of $year.\n";


This outputs

There are 29 days in February of 2016.

Copyright © Ben Bullock 2009-2023. All rights reserved. For comments, questions, and corrections, please email Ben Bullock ( or use the discussion group at Google Groups. / Privacy / Disclaimer