Operating System - HP-UX
1831349 Members
3001 Online
110024 Solutions
New Discussion

difference between 2 timestaps

 
SOLVED
Go to solution
weller
Advisor

difference between 2 timestaps

Hello

I look for a program or a function, me permitted to calculate like many time between two time stamps past.
Thank you for her assistance

M.Weller
6 REPLIES 6
Francisco J. Soler
Honored Contributor
Solution

Re: difference between 2 timestaps

Hi, Weller, you can obtain how many time between two time stamps with the attached script.

I have made the calculations in two ways,
one with awk, the other one with shell script, remove not wanted option.

if you name the script d_t (diff time) you could type the following:


./d_t "06/13/2003 10:00:00" "06/14/2003 12:10:10"

and the result will be:


Calculation in awk -----------------

Diff time in seconds: 94210
Diff time in minutes: 1570.167
Diff time in hours: 26.169
Diff time in days: 1.090

Calculation in shell ---------------

Diff time in seconds: 94210
Diff time in minutes: 1570
Diff time in hours: 26
Diff time in days: 1


hope this helps.

Frank.
Linux?. Yes, of course.
Jdamian
Respected Contributor

Re: difference between 2 timestaps

Francisco, does your script work ?

I read 'date -d' in the script.

My date commando doesn't accept '-d' option.
Jdamian
Respected Contributor

Re: difference between 2 timestaps

I also think the TIMEZONE should be in account because DayLight Savings would make the results to be wrong.
Francisco J. Soler
Honored Contributor

Re: difference between 2 timestaps

Hi, Damian

In fact at this moment i don't know if date -d works in HP-UX, i answer in linux forum and hp-ux forum too, so perhaps i checked this script in linux where "date -d" is correct.

I will check it in HP-UX and i will tell you the result.

Regards.
Frank.
Linux?. Yes, of course.
Francisco J. Soler
Honored Contributor

Re: difference between 2 timestaps

Hi Damian,

You are correct, HP-UX date does not support -d option, to solve this problem you can go to:

http://hpux.connect.org.uk/hppd/hpux/Gnu/sh_utils-2.0/

where are the gnu sh-utils, install it and you get the right date command version for HP-UX and my script.

Regards.
Frank.
Linux?. Yes, of course.
Chris Vail
Honored Contributor

Re: difference between 2 timestaps

Here's a quick C program I got off of ITRC t'other day. I didn't write it though, and I forget who did. It compiled and ran well.


Chris