- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Converting AMTIME1970 date to Human
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
Forums
Discussions
Discussions
Discussions
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
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
07-17-2002 01:45 PM
07-17-2002 01:45 PM
I have a text file that contains a field for date or time in seconds since AM 1970.
for exmaple
209515656 test1 test2 test3
209518655 test3 test2 test5
209523456 test1 test3 test1
.
.
.
How can I hadle this date format. I need to be able to convert this date column in this text file to this format
2002/07/15 for example.
I need to be able to do this thru out the file which contain over 60,000 lines...
I need this so I can upload this file into a mysql databse table ..
Do you think a simple script could do the trick or do you have any other suggestions
Thanks for any help
-Nabil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 01:51 PM
07-17-2002 01:51 PM
Re: Converting AMTIME1970 date to Human
I did a similar thing with perfview data (when exported) as it's exported in UTC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 01:54 PM
07-17-2002 01:54 PM
Re: Converting AMTIME1970 date to Human
Thanks for the reply ..Do you think you can help me with this...
Do you think a normal Ksh will do the conversion quick or need to get into compiling some C code ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 02:00 PM
07-17-2002 02:00 PM
Re: Converting AMTIME1970 date to Human
# TS=209515656
# echo "${TS}=Y" | adb
...would yield, 1974 Dec 15 02:44:22
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 02:06 PM
07-17-2002 02:06 PM
Solutionopen(INP,"
while(
chop;
if (/^(\d+)\s/) {
$sec1970=$1;
@a=localtime($a);
$new=sprintf "%4.4d/%2.2d/%2.2d",$a[5]+1900,$a[4]+1,$a[3];
s/$sec1970/$new/;
} else {
die "line does not begin with a number!";
}
print OUT $_,"\n";
}
This will create a newfile with the date (in seconds) converted to yyyy/mm/dd format.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 02:07 PM
07-17-2002 02:07 PM
Re: Converting AMTIME1970 date to Human
But what is adb ?? I don't think I have this bin file..
Also how do I plug the date after conversion back into the field and change it again to this format YYYY/MM/DD
Thanks again...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 02:09 PM
07-17-2002 02:09 PM
Re: Converting AMTIME1970 date to Human
@a=localtime($a);
to-
@a=localtime($sec1970);
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 02:19 PM
07-17-2002 02:19 PM
Re: Converting AMTIME1970 date to Human
Sorry, that timestamp was probably in decimal, so make the example:
# TS=209515656
echo "0d${TS}=Y" | adb
...which is 1976 Aug 21 18:47:36...
It's up to you to reformat it, which is why Rodney's solution using perl is nice.
'adb' stand for "absolute debugger'. Have a look at its man pages. It's 'usr/bin/adb' and has many, many uses.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2002 02:25 PM
07-17-2002 02:25 PM
Re: Converting AMTIME1970 date to Human
Thanks a bunch Rodney ..This answer deserves a lot more than 10 points...