idiot on perl idiot on perl - 1 year ago 116
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();

Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download