| Author |
Time difference calculation
|
|
| varkey 2007-12-30, 7:37 am |
| Hi,
I have a file which contains a set of time data as follows
16:37:45
15:45:52
13:48:20
00:20:23
i need to find the time difference with the present time.
Can anyone put some !dea ?
Thanks in advance
| |
| Ed Morton 2007-12-30, 7:37 am |
|
On 12/30/2007 6:37 AM, varkey wrote:
> Hi,
>
> I have a file which contains a set of time data as follows
>
> 16:37:45
> 15:45:52
> 13:48:20
> 00:20:23
>
> i need to find the time difference with the present time.
>
> Can anyone put some !dea ?
Are those times always in the past and are they always from the current day?
Ed.
| |
| Cyrus Kriticos 2007-12-30, 7:37 am |
| varkey wrote:
> I have a file which contains a set of time data as follows
>
> 16:37:45
> 15:45:52
> 13:48:20
> 00:20:23
>
> i need to find the time difference with the present time.
in seconds? All in the past but today?
$ echo $(( $(date +%s) - $(date -d '13:48:20' +%s) ))
211
--
Best regards
Cyrus
From a jewish slaughterhouse in Iowa (undercover)
http://video.google.com/videoplay?d...687976401601534
| |
| Cyrus Kriticos 2007-12-30, 7:37 am |
| varkey wrote:
> I have a file which contains a set of time data as follows
>
> 16:37:45
> 15:45:52
> 13:48:20
> 00:20:23
>
> i need to find the time difference with the present time.
in seconds? All from today?
[GNU date & bash]
$ echo $(( $(date +%s) - $(date -d '13:48:20' +%s) ))
211
--
Best regards
Cyrus
From a jewish slaughterhouse in Iowa (undercover)
http://video.google.com/videoplay?d...687976401601534
| |
| varkey 2007-12-30, 1:26 pm |
| Yeah i need to take the difference from the current time only.
| |
| Icarus Sparry 2007-12-30, 1:26 pm |
| On Sun, 30 Dec 2007 06:04:17 -0800, varkey wrote:
> Yeah i need to take the difference from the current time only.
The date command from the ast-open package has a '-E' (for elapsed)
option that does what you want.
You can get it under an Open Source license from
http://www.research.att.com/sw/download/
| |
| Ed Morton 2007-12-30, 1:26 pm |
|
On 12/30/2007 8:04 AM, varkey wrote:
[please wquote enough context for your post to stand alone, fixed below]
> Hi,
>
> I have a file which contains a set of time data as follows
>
> 16:37:45
> 15:45:52
> 13:48:20
> 00:20:23
>
> i need to find the time difference with the present time.
>
> Can anyone put some !dea ?
>
> Thanks in advance
>
> Yeah i need to take the difference from the current time only.
With GNU awk:
gawk '{gsub(/:/," ");print systime() - mktime(strftime("%Y %m %d ")$0)}' file
Regards,
Ed.
|
|
|
|