[aprssig] Wanted perl time code

Bruce Kreutzer ki4cpz at arrl.net
Wed Sep 2 06:45:04 EDT 2009


Andrew-

Perl has loads of time functionality.  The solution depends on what format
the date you have is in.  There is also very good perl documentation
online.  For example, google perl time diff.
I found this page as an overview:  http://www.perl.com/lpt/a/718

You can just subtract times in internal format:   $difftime = time() -
$prevtime;
Then print it using gmtime() to extract the individual values like this:
my @z = gmtime($difftime);
print "It has been $z(3) days, $z(2) hours, $z(1) minutes, $z(0) seconds
since we last heard xxxx";

(I haven't tried to actually run this code, but it should work).

There may be easier/better/faster ways to write this, but it's readable,
more or less.

I can't answer the mysql question.

Bruce
ki4cpz

On Wed, Sep 2, 2009 at 4:37 AM, Andrew Rich (Home) <vk4tec at tech-software.net
> wrote:

>  Hello
>
> I am looking for some perl code that can tell me the days, hours, minutes
> and seconds between two events
>
> Actually what I want is "It has been xxx since we last heard xxxx"
>
> Ideas ?
>
> Does MySQL have a time diff function ?
>
> ----------------------------------------------------------
> Andrew Rich
> Airways Technical Officer Grade 4
> Surveillance - RADAR ADS-B
> Amateur Radio Callsign VK4TEC
> email: vk4tec at tech-software.net
> web: www.tech-software.net
>
> _______________________________________________
> aprssig mailing list
> aprssig at tapr.org
> https://www.tapr.org/cgi-bin/mailman/listinfo/aprssig
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tapr.org/pipermail/aprssig_lists.tapr.org/attachments/20090902/16e71da4/attachment.html>


More information about the aprssig mailing list