My XML date input is : 2012-12-21 i.e. YYYY-MM-DD format. I want to convert month number into month name. i.e. 2012-Dec-21 Can anyone suggest which perl module is useful & how to use it with an example since I am very new to perl.
Use core perl's Time::Piece
:
#!/usr/bin/perl
use 5.10;
use strict;
use warnings;
use Time::Piece;
my $date = '2012-12-21';
# strftime format - http://www.unix.com/man-page/FreeBSD/3/strftime/
my $t = Time::Piece->strptime($date, '%Y-%m-%d');
say $t->month; # Dec
say $t->strftime('%Y-%b-%d'); # 2012-Dec-21
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With