- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Converting a date string of numbers to DD-MM-YYYY ...
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
09-25-2002 11:33 PM
09-25-2002 11:33 PM
Converting a date string of numbers to DD-MM-YYYY HH:MI:SS
We have a library application which runs an Oracle database and the Unix scripts are written in csh. Some log files have the date & time as a string of numbers while some log files have the date as normal dd-mm-yyyy etc.
Does anyone know how I can convert the date string of numbers into DD-MM-YYYY HH:MI:SS
eg Batch Log
10117922575821 29651 p_manage_18 Library PTK01 locked in param
10117928490194 29651 p_manage_18 end 10117928494564 29651
p_manage_18 Library PTK01 unlocked
vs. equivalent Util/C/11 [some times not accessible]
23-01-2002 15:24:17 p_manage_18 Library PTK01 locked in
param 23-01-2002 15:34:09 p_manage_18 end 23-01-2002
15:34:09 p_manage_18 Library PTK01 unlocked
Many Thanks
Vinesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2002 11:53 PM
09-25-2002 11:53 PM
Re: Converting a date string of numbers to DD-MM-YYYY HH:MI:SS
perl would be my choice:
# perl -e "@t=localtime(substr(shift,0,10));printf\"%02d-%02d-%04d %02d:%02d:%02d\n\",@t[3],@t[4]+1,@t[5]+1900,@t[2],@t[1],@t[0]" 10117922575821
23-01-2002 13:24:17
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 12:12 AM
09-26-2002 12:12 AM
Re: Converting a date string of numbers to DD-MM-YYYY HH:MI:SS
Well I have now discovered that we do not have perl. Where can I download this from or do you have an alternative. By the way, what format is this date string in?
Vinesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 12:31 AM
09-26-2002 12:31 AM
Re: Converting a date string of numbers to DD-MM-YYYY HH:MI:SS
#include
#include
int
main (int argc, char *argv[])
{
time_t outdate;
char buffer[80];
int timestamp;
if (argc==1) timestamp=time(NULL); else timestamp=atoi(argv[1]);
strftime (buffer, 80, "%d-%m-%Y %H:%M:%S", localtime (×tamp) );
printf ("%s\n", buffer );
return 0;
}
- copy and paste it in a file
- cc
- rename the file "a.out" to e.g. uxtime2date
- run "uxtime2date 1011792257"
(without the last 4 digits)
- without an argument the actual date is displayed
I have attached an compiled version
Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 12:47 AM
09-26-2002 12:47 AM
Re: Converting a date string of numbers to DD-MM-YYYY HH:MI:SS
You should be able to download the Perl 5.6.1. depot from:
http://hpux.connect.org.uk/hppd/hpux/Languages/perl-5.6.1/
or any other mirrored site shown on the home page.
I am only familiar with the 10-digit date format, which is the number of seconds since 1st January 1970. That's why I truncated the 14-digit number that is in your logfile.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 03:20 AM
09-26-2002 03:20 AM
Re: Converting a date string of numbers to DD-MM-YYYY HH:MI:SS
not precisely the format you want, but easy to achieve:
# TOTAL_NUMBER_OF_SECS=10117922575821
# REDUCED_NUMBER_OF_SECS=`echo $TOTAL_NUMBER_OF_SECS | cut -c1-10`
# echo "0d${REDUCED_NUMBER_OF_SECS}=Y" | adb
The output depends on the setting of your TZ variable (influences many other time functions).
Output on my system:
# 2002 Jan 23 15:24:17
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 10:52 PM
09-26-2002 10:52 PM
Re: Converting a date string of numbers to DD-MM-YYYY HH:MI:SS
Just to precise the date format: it is the french date format.
In France, we read the date starting with the day, then the month and finally the year.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2002 01:33 AM
09-27-2002 01:33 AM