sreek3502 has asked for the wisdom of the Perl Monks concerning the following question:
Hi experts, Can you please check below code to get the customized date and time output, Please see the expected output
#!/usr/bin/perl -w use POSIX; my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(ti +me); $year += 1900; print "$sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst\n"; $now_string = localtime; print "$now_string\n"; $date = strftime "%a %b %e %H:%M:%S %Y", localtime; print "Date1 is : $date\n"; $date = strftime "%a-%B-%e", localtime; print "Date2 is : $date\n"; $time = strftime "%H:%M:%S", localtime; print "Time1 is : $time\n"; $time1 = strftime "%h:%m:%s", localtime; print "Time2 is : $time1\n";
#OUTPUT #Date1 is : 06-Oct-2017 #Date2 is : 06-10-2017 #Time1 is : 23:35:10 #Time2 is : 11:35:10 PM
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: date and time using localtime
by haukex (Archbishop) on Oct 07, 2017 at 08:20 UTC | |
by BillKSmith (Monsignor) on Oct 07, 2017 at 20:17 UTC | |
by haukex (Archbishop) on Oct 08, 2017 at 08:37 UTC | |
by Anonymous Monk on Oct 07, 2017 at 20:28 UTC | |
|
Re: date and time using localtime
by BillKSmith (Monsignor) on Oct 06, 2017 at 20:00 UTC | |
|
Re: date and time using localtime
by thanos1983 (Parson) on Oct 09, 2017 at 09:06 UTC | |
by hippo (Archbishop) on Oct 09, 2017 at 13:06 UTC | |
by thanos1983 (Parson) on Oct 10, 2017 at 08:04 UTC |