idiot on perl idiot on perl - 3 months ago 15
Perl Question

How to format local time to mm/dd/yyyy HH:MM:SS AM/PM in Perl

I need to convert the local time to exact format as

mm/dd/yyyy HH:MM:SS AM/PM

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();


By using strftime of POSIX module you can get the desire result:

use POSIX qw/strftime/;
print strftime('%d-%m-%Y %I:%M:%S %p',localtime);