CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
time troubles


New User

Sep 10, 2002, 7:06 AM

Post #1 of 3 (1015 views)
time troubles Can't Post


I'm pretty new (but not pretty)to perl scripting so i need some help.

I am trying to develop a script which will look at a text file, extract the time for a user logon then compare it with the logoff time then display both plus duration of session.

I have extracted the information to two separate files, but need a pointer to which module i need to use (and the syntax used) to perform the time calculation.

Thanks in advance


Thaumaturge / Moderator

Sep 10, 2002, 12:37 PM

Post #2 of 3 (1011 views)
Re: [Allansky] time troubles [In reply to] Can't Post

It depends what format your times are in, but here's an example.

#! /usr/bin/perl -w 

use strict;
use Time::Piece;

my $t1 = Time::Piece->strptime('12:30:00', '%H:%M:%S');

my $t2 = Time::Piece->strptime('12:35:40', '%H:%M:%S');

my $diff = $t2 - $t1;

print "Diff is ", $diff->seconds, " seconds\n";

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks

New User

Sep 11, 2002, 2:07 AM

Post #3 of 3 (1006 views)
Re: [davorg] time troubles [In reply to] Can't Post

Thanks, I'll give it a whirl!Tongue


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives