in reply to perl script to calculate beg and end of current month
You can also use Time::Local, as shown below. It's not the friendliest module, but it comes with perl.
use Time::Local qw( timegm_nocheck ); my ($y, $m, $d) = (localtime)[5,4,3]; $y += 1900; $m += 1; my $ds = 1; my $de = (gmtime(timegm_nocheck(0,0,0, (1-1), ($m+1)-1, $y)))[3]; printf "start: %04d-%02d-%02d\n", $y, $m, $ds; printf " end: %04d-%02d-%02d\n", $y, $m, $de;
Keep in mind the last day of the month is the day before first day of the next month.
|
|---|