1833882 Members
3817 Online
110063 Solutions
New Discussion

Re: Date Conversion

 
SOLVED
Go to solution
Giuseppe_13
Frequent Advisor

Date Conversion

How is possible in HP-UX 11.0, to convert
a date from hexadecimal format to usual format ?

thanks
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Date Conversion

You need to clarify what you mean by hexadecimal format. If you are referring to
epoch seconds (seconds since 1-Jan-1970 00:00:00 UTC) then

perl -e 'print scalar localtime(1000)'

where 1000 = 1000 seconds after 1-Jan-1700 00:00:00

or if hex:
perl -e 'print scalar localtime(hex("0x1000"))'

Man perlfunc for more details.

If it ain't broke, I can fix that.
Stephen Keane
Honored Contributor

Re: Date Conversion

Write a C program that takes the date in hexadecimal (presumably seconds since the Epoch?) and calls localtime() and strftime() to convert it into an ASCii string. Can't think of a way to do it in shell, probably is a smart way of doing it in Perl though.
Stephen Keane
Honored Contributor

Re: Date Conversion

told you!!
Giuseppe_13
Frequent Advisor

Re: Date Conversion

Yes, i refer to epoch seconds (seconds since 1-Jan-1970 00:00:00 UTC).
Seconds in hex format.


# perl -e 'print scalar localtime(hex("0x4131d0ca"))'

output:
Sun Aug 29 14:49:14 2004


thanks


Giuseppe_13
Frequent Advisor

Re: Date Conversion

Problem solved by forum member.

Thanks