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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
time troubles

 



Allansky
New User

Sep 10, 2002, 7:06 AM

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

hi,

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

Al.Crazy


davorg
Thaumaturge / Moderator

Sep 10, 2002, 12:37 PM

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

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

Code
#! /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
http://www.dave.org.uk/
Get more help at Perl Monks


Allansky
New User

Sep 11, 2002, 2:07 AM

Post #3 of 3 (467 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