ziggy6
1
Good day.
I am trying to change the output on my date so that I can get the month as a numeric value.
TODAY=`perl -e 'print localtime(time()) . "\n" '`
Here are the results from the above perl statement
Thu Feb 11 13:16:40 2016
I am not sure of the syntax to get a date more like 10/20/2016 or anything that gives me a numeric value for the month day and year.
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
printf "%02d/%02d/%d\n", $mon+1, $mday, $year + 1900;
printf "raw year: $year\n";
printf "raw month: $mon\n";
printf "raw day of month: $mday\n";
Some the values returned by localtime are not what you think -year starts with 1900, month is zero based = January = 0
output:
02/11/2016
raw year: 116
raw month: 1
raw day of month: 11
1 Like
Aia
3
Would that work?
perl -MPOSIX="strftime" -le 'print strftime("%m/%d/%Y", localtime)'
02/11/2016
1 Like