Tha date command, one of the eldest tools in Unix has got one quirk that escaped me all those years. As usual with these things, it was a delegate who pointed this out to me, with a wry smile.
A bit of background first. If you need to extract hour and minutes from the date command, you'd probably use:
$ date +%H:%M
14:48
The little 'inverted polish logic' (is that why they keep telling me these things? ;-) ) is if you try to use the AM/PM indicator, achieved with the 'p' options.
Try the following:
$ date +%H:%M\ %p
14:49 PM
Then try:
$ date +%H:%M\ %P
14:49 pm
Don't know the background to this, but it does appear a deliberate tease ;-)
Twitter Updates
G-AVLN in front of her home
Mostly Unix and Linux topics. But flying might get a mention too.
Subscribe to:
Post Comments (Atom)
Blog Archive
- October (1)
- June (1)
- April (2)
- February (3)
- June (1)
- March (1)
- August (3)
- July (2)
- June (1)
- March (1)
- June (3)
- May (1)
- April (5)
- February (1)
- January (5)
- October (1)
- September (3)
- July (4)
- June (5)
- April (3)
- March (1)
- February (3)
- January (3)
- October (7)
- August (2)
- July (3)
- May (1)
- November (4)
- October (1)
- September (1)
- August (2)
- July (2)
- June (3)
- May (3)
- April (2)
- March (2)
- February (3)
- January (1)
- December (2)
- November (1)
- October (6)
- September (6)
- August (1)
- July (2)
- June (8)
- May (3)
- April (4)
- March (3)
2 comments:
The reason is as follows: the %p format comes from the SUS/POSIX, and uses the format specified in the locale (not necessarily upper case). GNU wanted to added another option for lower case, and they choose %P. %P does not exist in standard (non-GNU) versions of date. See also the man pages for strftime(3).
Ahh - that explains. Except that both HP and Solaris (just checked their man pages) use the GNU version...
Post a Comment