Time difference calculation
Time difference calculation
am 30.12.2007 13:37:01 von Anup V
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
Re: Time difference calculation
am 30.12.2007 13:43:11 von Ed Morton
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.
Re: Time difference calculation
am 30.12.2007 13:53:41 von Cyrus Kriticos
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?docid=-7960687976401601534
Re: Time difference calculation
am 30.12.2007 13:56:21 von Cyrus Kriticos
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?docid=-7960687976401601534
Re: Time difference calculation
am 30.12.2007 15:04:17 von Anup V
Yeah i need to take the difference from the current time only.
Re: Time difference calculation
am 30.12.2007 18:13:00 von Icarus Sparry
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/
Re: Time difference calculation
am 30.12.2007 19:04:25 von Ed Morton
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.