The Posix-module has a very nice function called strftime() that is capable of formatting dates and times to a human readable format.
But ... the manpage is not very descriptive. It tells you nothing about the meanings of the parameters in the format string.
Unix/Linux users can read about them by typing
Therefore, in the hope it will help somebody*, i post this little script, that can serve both as a reference and as an example.
Notes:
The parameters %U and %W, are not identical. %U starts counting the Week Of Year at sundays, %W starts counting on mondays.
The %p parameter can be empty, depending on the locale of the system.
*and for my own convenience
Update: corrected typo for %M
Update: corrected typo for %I (thanks bmann)
Update: retitled node from "strftime reference" to "strftime reference for win32"
holli, /regexed monk/
But ... the manpage is not very descriptive. It tells you nothing about the meanings of the parameters in the format string.
Unix/Linux users can read about them by typing
(thanks blokhead for advising me on that), but Windows users are lost.$ date --help
Therefore, in the hope it will help somebody*, i post this little script, that can serve both as a reference and as an example.
use strict; use POSIX qw(strftime); print strftime qq{ a: Day of Week (short, text) %a A: Day of Week (long, text) %A b: Monthname (short, text) %b B: Monthname (long, text) %B c: Full datetime (number, long) %c d: Day (number) %d H: Hour (24 hour) (number) %H I: Hour (12 hour) (number) %I j: Day of year (number) %j m: Month (number) %m M: Minutes (number) %M p: am/pm/empty (text) %p S: Seconds (number) %S U: Week of Year (number) %U w: Day of week (number) %w W: Week of Year (number) %W x: date (number) %x X: time (number) %X y: year (short, number) %y Y: year (long, number) %Y Z: timezone (text) %Z }, localtime;
Notes:
The parameters %U and %W, are not identical. %U starts counting the Week Of Year at sundays, %W starts counting on mondays.
The %p parameter can be empty, depending on the locale of the system.
*and for my own convenience
Update: corrected typo for %M
Update: corrected typo for %I (thanks bmann)
Update: retitled node from "strftime reference" to "strftime reference for win32"
holli, /regexed monk/
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: strftime reference
by bmann (Priest) on Feb 24, 2005 at 18:40 UTC | |
by holli (Abbot) on Feb 24, 2005 at 18:44 UTC | |
by Anonymous Monk on Jun 26, 2010 at 02:20 UTC | |
Re: strftime reference
by Joost (Canon) on Feb 24, 2005 at 23:47 UTC | |
Re: strftime reference
by lachoy (Parson) on Feb 24, 2005 at 21:17 UTC | |
by astroboy (Chaplain) on Feb 24, 2005 at 21:56 UTC | |
by lachoy (Parson) on Feb 24, 2005 at 23:17 UTC | |
Re: strftime reference
by trammell (Priest) on Feb 24, 2005 at 22:52 UTC | |
Re: strftime reference
by blahblahblah (Priest) on Feb 24, 2005 at 19:30 UTC | |
Re: strftime reference
by demerphq (Chancellor) on Feb 25, 2005 at 17:34 UTC | |
Re: strftime reference
by Anonymous Monk on Feb 28, 2005 at 11:03 UTC | |
by holli (Abbot) on Feb 28, 2005 at 14:02 UTC | |
Re: strftime reference
by bart (Canon) on Feb 25, 2005 at 15:13 UTC |
Back to
Meditations