- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Converting timestamp to date/time
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
12-05-2001 08:37 AM
12-05-2001 08:37 AM
Also, is there a function that will do this? If so, how is it used?
Any help will be greatly appreciated!
Thanks,
jls
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 08:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 08:42 AM
12-05-2001 08:42 AM
Re: Converting timestamp to date/time
----------------------------------------
Here is the information on how to convert from EPOCH time (time in seconds since 1/1/1970) to our HUMAN time.
There is also an SQL select statement example showing how to convert from EPOCh to HUMAN time included below.
In addition, there is code included that shows how to print the current EPOCH time.
1. Conversion from EPOCH to HUMAN time:
The following is the source code in 'C':
#include
main(argc, argv)
int argc;
char **argv;
{
time_t foo;
foo = atoi(argv[1]);
printf("%s",ctime(&foo));
}
1a. Create a vi file (with extension .c) that includes the above lines.
For example: vi time.c
From the command line type the following:
cc (filename)
For example: cc time.c
This should create an a.out file in same directory.
1b. Simply run the command:
For example:
./a.out 913097859 <<<---digits you want converted
Your output will look like:
Tue Dec 8 00:17:39 1998
2. The SQL 'select' statement can be used to convert ITO Oracle EPOCH fields to human time:
select
TO_DATE(TRUNC(creation_time/ 86400) + 2440588, 'J'),
TO_CHAR(TO_DATE(MOD(creation_time, 86400), 'SSSSS'),'HH24:MI:SS')
from opc_op.opc_act_messages
where node_id = '
3. Here is source code in 'C' to print current time in EPOCH time:
#include
main()
{
printf("%ld\n",time(NULL));
}
3a. Create a vi file (with extension .c) that include the above lines.
For example: vi time.c
From the command line type the following:
cc (filename)
For example: cc time.c
This should create an a.out file in same directory.
3b. Simply run the command:
For example:
./a.out
Remember EPOCH fields will expire (reach their limit at) year 2037
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 08:42 AM
12-05-2001 08:42 AM
Re: Converting timestamp to date/time
#include
int main(argc, argv)
int argc;
char **argv;
{
time_t t=strtoul(argv[1], NULL, 0);
printf("%s", ctime(&t));
}
/* end */
$ cc -o ctime ctime.c
$ ./ctime 1007570579
Wed Dec 5 16:42:59 2001
Regards,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 09:03 AM
12-05-2001 09:03 AM
Re: Converting timestamp to date/time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 09:13 AM
12-05-2001 09:13 AM
Re: Converting timestamp to date/time
THANKS TO ALL!
jls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2001 09:55 AM
12-05-2001 09:55 AM
Re: Converting timestamp to date/time
C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2002 08:08 AM
02-28-2002 08:08 AM
Re: Converting timestamp to date/time
#include
#include
#include
main()
{
time_t maxt = LONG_MAX; /* 2147483647L */
printf("The end of time as we know it is %s GMT\n",
asctime(gmtime(&maxt)));
maxt = maxt + 1;
printf("One second after will be (in 32bits) %s GMT\n",
asctime(gmtime(&maxt)));
}
$ ./timemach
The end of time as we know it is Tue Jan 19 03:14:07 2038
GMT
One second after will be (in 32bits) Fri Dec 13 20:45:52 1901
GMT
$
live free or die
harry