Get the last day of a month

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

#!/home/ben/software/install/bin/perl
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";

(download)

This outputs

There are 29 days in February of 2016.


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