Gossamer Forum
Quote Reply
Last day in month
Hey,

i have a variable "year=2005" and "month=09" and need to set exact the last day of this month.
e.g.: "set lastday = 2005-09-31".

How can i find the last day from a month out?

Thanks in advance!

Coyu
Quote Reply
Re: [Coyu] Last day in month In reply to
Did you look at the date/time utilities available from Date::Calc in cpan, and the pure-perl version of Perl::Calc ??


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Coyu] Last day in month In reply to
Hi,

Here's my global for doing this:

sub {
my @monthDays = qw( 31 28 31 30 31 30 31 31 30 31 30 31 );
my $month=shift;
my $year=shift; $year or $year=date_get(time,"%yyyy%");
if ((2 == $month) and (0 == $year%4)){return 29;}
else {return $monthDays[$month-1]};
}

<%globalname($month,$year)%>

Laura.