Re: date format option (248 Views)
Reply
Regular Advisor
blackwater
Posts: 129
Registered: ‎05-14-2009
Message 1 of 10 (248 Views)
Accepted Solution

date format option

I read online documentation for the date command http://docs.hp.com/en/B2355-90689/date.1.html.
According to it there is no format option +%s. However when I run this command:
/usr/bin/date +%s
I get a correct result:
1281507492

Why do you not include this format option in your documentation?

Honored Contributor
Michal Kapalka (mikap)
Posts: 2,683
Registered: ‎08-19-2007
Message 2 of 10 (248 Views)

Re: date format option

hi,

yes you have right, there is no this entry in the manapage, but if you look into general man page ( Unix ) you will find this :

%s seconds since 1970-01-01 00:00:00 UTC

mikap
Honored Contributor
Matti_Kurkela
Posts: 6,271
Registered: ‎12-02-2001
Message 3 of 10 (248 Views)

Re: date format option

By using the "Complete book in PDF" link and check the copyright and publication information in the first pages of the book/PDF.

The document you were reading is the first edition of HP-UX 11.11 man pages, published in December 2000. It's almost 10 years old.

I'm pretty sure this functionality didn't exist in 11.11 in about 2002/2003. I guess it may have been added by some patch after that. At that time, I wrote a tiny C program to overcome the problem.

Which version of HP-UX you're using? ("uname -a" please)

If the option exists but the installed manpage for date(1) on your system doesn't know about it, then it can be said it's a documentation bug.

MK
MK
Regular Advisor
blackwater
Posts: 129
Registered: ‎05-14-2009
Message 4 of 10 (248 Views)

Re: date format option

I am using HP 11.31.

I have taken a look at "HP-UX Reference" (2007) and the manpage on the server. Seems like +%s is not documented.
Honored Contributor
Raj D.
Posts: 2,624
Registered: ‎06-12-2004
Message 5 of 10 (248 Views)

Re: date format option

Correct, the +%s option is not there in the man page: I checked ( page 205 )of the blackwater,
command referene, it is good that you found it, HP may include it in the next KB Knowledge base document,

http://docs.hp.com/en/B2355-91017/B2355-91017.pdf ## Page 205 (11.31)

---
date(1) date(1)
NAME
date - display or set the date and time
------

Cheers ,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Acclaimed Contributor
Dennis Handly
Posts: 25,294
Registered: ‎03-06-2006
Message 6 of 10 (248 Views)

Re: date format option

It appears that %s also works on 11.23.
Honored Contributor
Bill Hassell
Posts: 14,226
Registered: ‎05-29-2000
Message 7 of 10 (248 Views)

Re: date format option

Based on some average 11.00, 11.11, 11.23 and 11.31 systems, date %s works starting with 11.23 and fails in anything prior. Yet another item that fell through the documentation gap. It was probably added as a simple change to the date command along with other enhancements and the author forgot to write up the details.
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 8 of 10 (248 Views)

Re: date format option

Hi:

> Bill: Based on some average 11.00, 11.11, 11.23 and 11.31 systems, date %s works starting with 11.23 and fails in anything prior.

And in that case, since all of the aforementioned releases had Perl, simply do:

# perl -le 'print time()'

Regards!

...JRF...
Regular Advisor
blackwater
Posts: 129
Registered: ‎05-14-2009
Message 9 of 10 (248 Views)

Re: date format option

It is a insignificant bug in the technical documentation.
Acclaimed Contributor
Dennis Handly
Posts: 25,294
Registered: ‎03-06-2006
Message 10 of 10 (248 Views)

Re: date format option

This was implemented on 11.23 in strftime(3) with QXCR1000509179 for Linux compatibility.

I filed an enhancement QXCR1001066009 to document this for strftime(3) and date(1).
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.