Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Calculating Time
Name: Xerex Date: May 6, 2004 at 22:54:09 Pacific OS: UNIX Solrais ( SUN OS) CPU/Ram: ULTRA 5
Comment:
Hi Everyone,
Do anybody now how to calculate the time say for example the time rendered by an employee at work. What arithemetic commands should I use? Say for example:
Time in 2:00:00 Time out 6:00:00 Time in 7:30:00 Time out 10:30:00
If you have access to gawk (the GNU version of awk) it comes with mktime (which converts a date string to a number of seconds since 01 Jan 1970) and strftime (which converts back). For an example see shift_date.awk.
You can also script the whole thing yourself by splitting the time string into its component parts and using modulus ("%"), e.g. in ksh:
$ print $(( 75 % 60 )) 15
$ print $(( 75 / 60 )) 1
0
Response Number 3
Name: Xerex Date: May 14, 2004 at 21:41:06 Pacific
Reply:
Hi,
Thanks Nails. I got my mind twisted with this time calculation. :) But it was enriching.
Summary: Hello, I want to know how to calculate time difference in unix shell script. Time command in unix will not solve my problem because it calculates total time taken by a script. See the examle below. ...
Summary: Hi I wonder if you can help me to calculate the time difference between to times. Here is my file: 11:56:34 354940 5240832 453754 11:58:16 354788 5240832 453753 I need to subtract th...
Summary: Hi all, I have search in this forum and find some answer to use time (command) to calculate the elapsed time. I tried to take the output of time i.e. the elapsed time only. But I still want the (comm...