Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How can I format the output of localtime?

by Zaxo (Archbishop)
on Feb 12, 2004 at 03:48 UTC ( [id://328472]=note: print w/replies, xml ) Need Help??


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".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://328472]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-24 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found