http://qs321.pair.com?node_id=328472


in reply to How can I format the output of localtime?

The most convenient formatter for localtime output is &POSIX::strftime. It is similar to an sprintf call, taking a format string as its first argument, and a localtime compatible list as the remaining arguments. The formats are specialized for time units, and extract the strings without need for displacements in the data. The complete list of formats is given in man 3 strftime. A locale-sensitive date can be formatted with the "%x" format string:
use POSIX 'strftime'; my $datestring = strftime 'Today is %x.', localtime; print $datestring, $/;
The format inquired of is given (with leading zeros) by the "%D" format string. Full names of months and days in the language of the current locale are given by the "%B" and "%A" formats, and their abbreviations by "%b" and "%a".