G'day oikool,
You can use the built-in module Time::Piece for this task. Check the documentation for different representations of year (e.g. 2-digit or 4-digit) and month (e.g. number: starting at 0 or 1; or name: full or abbreviated). Here's the basic code:
#!/usr/bin/env perl -l use strict; use warnings; use Time::Piece; my $t = localtime($^T); print 'Month: ', $t->month; print 'Year: ', $t->year;
Output:
Month: Feb Year: 2014
-- Ken
In reply to Re: extract month and year from localtime
by kcott
in thread extract month and year from localtime
by oikool
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |