06-11-2001 05:38 PM
I am trying to write some scripts for ITO and see the date and time of the message received and compare it with the local time. if the message is sitting there for more than 30 mins I want to generate some alerts for operatiors.
This date filed in the IT/O database is in the form of seconds. It stores the date in number of seconds Since 1st Jan 1970. It means the current entry will be (60 * 60 min * 24 Hr * 365 days* 31 yrs ) seconds OR something similar
looks strange isn't it.... Well.. IT/O must be running some commands to calculate this seconds to date before displaying it on the message browser.
I want to know how can convert these seconds in to date so that I can compare it with current date and time. what commands I can use to get the current date in to number of seconds OR seconds available in the database in to date format
Thanks for your time
Solved! Go to Solution.
06-12-2001 01:36 AM
You can do that with a small part of C code (
see at the end to have an example). You can
use some C functions to do this (man ctime to
have all informations needed).
Compile with : cc
And start with : ./a.out
char ** args;
/* Here you translate args 1 : first time entered in seconds */
time_t my_time1 = atoi (args);
/* Here you translate args 2 : second time entered in seconds */
time_t my_time2 = atoi (args);
/* Now you can display dates using local time parameters like timezone,
summer time,... */
printf ("\nThe first date in parameter is : %s\n",asctime (localtime (&my_time1)));
printf ("\nThe second date in parameter is : %s\n",asctime (localtime (&my_time2)));
06-13-2001 03:48 AM
will display the # secs since 1/1/70. Then use "bc" or your favourite unix number crunching command to work out the difference from your ITO figure.