- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Converting UNIX epoch time to a date formatted...
Operating System - HP-UX
1753862
Members
7491
Online
108809
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО09-21-2006 03:11 AM
тАО09-21-2006 03:11 AM
Hi,
I'm attempting to convert a UNIX epoch time obtained with the command shown below to a date having the format of %y%m%d%H%M%S:
sprnorda@aix% truss date 2>&1 | awk '/time/ {print $NF}'
1158845395
I'm not sure how I could pass the value "1158845395" to the 'date' utility.
I do have a Perl script which does that. However, i'd want to know how it should be done using any UNIX utilities or scripts.
Could anyone help me out?
Thanks
Danny
I'm attempting to convert a UNIX epoch time obtained with the command shown below to a date having the format of %y%m%d%H%M%S:
sprnorda@aix% truss date 2>&1 | awk '/time/ {print $NF}'
1158845395
I'm not sure how I could pass the value "1158845395" to the 'date' utility.
I do have a Perl script which does that. However, i'd want to know how it should be done using any UNIX utilities or scripts.
Could anyone help me out?
Thanks
Danny
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2006 03:23 AM
тАО09-21-2006 03:23 AM
Re: Converting UNIX epoch time to a date formatted %y%m%d%H%M%S
Danny,
from another site:
$ timer=1158845395
$ echo "0d$timer=Y" | adb | tr -d '\011'
2006 Sep 21 14:29:55
from another site:
$ timer=1158845395
$ echo "0d$timer=Y" | adb | tr -d '\011'
2006 Sep 21 14:29:55
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2006 03:24 AM
тАО09-21-2006 03:24 AM
Re: Converting UNIX epoch time to a date formatted %y%m%d%H%M%S
Hi Danny:
# perl -MPOSIX=strftime -e 'print strftime("%m%d%H%M%Y\n",localtime($ARGV[0]))' 1158845395
...returns:
092109292006
Regards!
...JRF...
# perl -MPOSIX=strftime -e 'print strftime("%m%d%H%M%Y\n",localtime($ARGV[0]))' 1158845395
...returns:
092109292006
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2006 03:27 AM
тАО09-21-2006 03:27 AM
Solution
Hi (again):
Oh, you wanted :%y%m%d%H%M%S", so:
# perl -MPOSIX=strftime -e 'print strftime("%y%m%d%H%M%S\n",localtime($ARGV[0]))' 1158845395
You can use any standard format that you want. Follow the directives in the man pages for 'strftime(3C)' or for 'date(1)'.
Regards!
...JRF...
Oh, you wanted :%y%m%d%H%M%S", so:
# perl -MPOSIX=strftime -e 'print strftime("%y%m%d%H%M%S\n",localtime($ARGV[0]))' 1158845395
You can use any standard format that you want. Follow the directives in the man pages for 'strftime(3C)' or for 'date(1)'.
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP