- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- date conversion
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2010 08:41 AM
тАО03-23-2010 08:41 AM
I need to convert date from this format:
Tue Mar 23 18:31:08 EET 2010
in something like this
07DA0317101F2B00
07da-year
03-mounth
17-day
10-hour
1f-min
2b-sec
00-decsec
I tried to do it with this command
printf "%x" `date "+ %Y %m %d %H %M %S"`
but the result it's not what I want, it looks like this
7DA317101F2B
7da-year
3-mounth
17-day
10-hour
1f-min
2b-sec
Are missing some zerous :)
There is a way to have all zeros?
server: RP4440
sw:B 11.11
BR,
dublonn
Solved! Go to Solution.
- Tags:
- date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2010 08:53 AM
тАО03-23-2010 08:53 AM
Re: date conversion
Why not:
# print $(date "+%Y%m%d%H%M%S")
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2010 08:57 AM
тАО03-23-2010 08:57 AM
Re: date conversion
It's work but I need in hexa not in decimal...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2010 09:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2010 11:32 AM
тАО03-23-2010 11:32 AM
Re: date conversion
For grins-and-giggles, we can shorten things:
# perl -e '@t=localtime;printf "%03x%02x%02x%02x%02x%02x\n",$t[5]+1900,$t[4]+1,@t[3,2,1,0]'
For that matter, you can convert any Epoch seconds to a hexadecimal number representing the date components. For me, in the Eastern US, 999,999,999 seconds after the Epoch yielded 0x7d10908152e27 or 20010908214639 (2001-09-08-21:46:39).
# perl -e '@t=localtime(999_999_999);printf "%03x%02x%02x%02x%02x%02x\n",$t[5]+1900,$t[4]+1,@t[3,2,1,0]'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2010 08:29 PM
тАО03-23-2010 08:29 PM
Re: date conversion
dublonn, what problem are you really trying to solve (and why)?
Do you have the time itself as input, or do you have a piece of string in "Day Mon dd hh:mm:ss zon yyyy" format at input?
Frankly I suspect that the problem description is all wrong.
In my world it makes no sense at all to convert individual date & time components to hexadecimal other than to confuse the romanians (feeble joke).
And where does the deci-seconds component come from?
It wouldn't surprise me if the hex is supposed to be a simple formating of the time since epoch in seconds
>perl -e "$x=time();printf qq(%d %x\n),$x,$x"
1269403997 4ba9915d
That brings a 14 byte yyyymmddhhmmss (localtime reformatted) through a 10 digit decimal number, down to an 8 character hexadecimal string, utilizing all positions fully.
Your request seems to ask that for example the minute component instead of going from 00-59 (not using 60 - 99) uses 00-4B (not using 4C-FF). Why?
Hope this help clarify a little,
Cheers,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2010 11:29 PM
тАО03-23-2010 11:29 PM
Re: date conversion
the right command for me is:
perl -e '@t=localtime;printf "%04x%02x%02x%02x%02x%02x%02x\n",$t[5]+1900,$t[4]+1,@t[3,2,1,0]'
the result is : 07da031809170c00
exactly what I need it.
Mr Heuvel,
I need date in this format because I have to synconize some eq from the network which support only hexa format and that type of format.
BR,
dublonn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2010 03:38 AM
тАО03-24-2010 03:38 AM
Re: date conversion
Thin input date format was 32 bit- binary where the question asked about a piece of string: From this format Tue Mar 23...
>> I need date in this format because I have to synconize some eq from the network which support only hexa format and that type of format.
Thank you for explaining.
Best regards,
Hein.