Perlで翌月の月末を求め、yyyyMMddで表示する計算があったので対応。
知識がなかったんで何気にちょい時間がかかりました。PerlではこのDateTimeというライブラリがよさげ。
1 2 3 4 5 6 |
use DateTime; my $today = DateTime->now; my $from = DateTime->new( year => $today->year, month => $today->month , day=>1 )->add(months => -1, end_of_month => "preserve")->ymd('/'); my $next_month = DateTime->now->add(months => 1, end_of_month => "preserve"); my $to = DateTime->last_day_of_month( year => $next_month->year , month => $next_month->month )->ymd('/'); |
参考リンク
http://monmon.hateblo.jp/entry/20100428/1272438175
http://iandeth.dyndns.org/mt/ian/archives/000619.html
http://memo.sugyan.com/entry/20140131/1391177666