develooper Front page | perl.beginners | Postings from March 2002

time calculation [2]

Thread Next
March 19, 2002 10:21
time calculation [2]
Message ID:
I get the input from an html form (I'm trying to create a page where
employees could submit their work hours - "timesheets").
The time_in is the hour picked from a list/menu box. I'm not sure what value
I should pass to the script; I thought numbers 0 through 24 would be a good
idea (starting at 12am as 0). And then the time passed would be $time_out -
$time_in (e.g. 9am to 5pm would be 17-9=8hrs worked). But that doesn't work
for one instance - when the time_out is 12am. I was wondering if anyone had
to make a similar calculation in any of their scripts; it's rather the
question for the logic solution I guess not the script itself.

----- Original Message -----
From: "Mariusz" <>
To: "perl" <>
Sent: Tuesday, March 19, 2002 12:56 AM
Subject: time calculation

What's the best way to find the difference in hours between $checkin_time
and $checkout_time?
I thought each hour from 12am through 12pm would supply integer from 0 to 24
(e.g. 9am to 5pm is 17-9=8) but that does work except when checkout is
12am.(I don't have to deal with minutes in this script)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About