How To Get Last Day Of Current Month With Suffix Using PERL
erics, Posted May 28th, 2011 at 5:22:18pm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
use Date::Manip; my @months = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; my $month = $months[ (localtime)[4] ]; my $last = &UnixDate("last saturday in $month", "%B %e"); $last .= &gensuffix($last); sub gensuffix { my($val) = @_; my $end_num = substr($val, -1, 1); my $suffix = 'th'; $suffix = 'st' if $end_num == 1; $suffix = 'nd' if $end_num == 2; $suffix = 'rd' if $end_num == 3; return $suffix; } |
Leave Your Comment
All fields marked with "*" are required.