PDA

View Full Version : Time in Hours and minutes


Dfw
02-02-2003, 03:07 AM
I have built a HTML form for my employees to enter a job and the time they were on the job. It goes like this: TimeOn (enter time HH:MM) TimeOff (Enter HH:MM). I would like to format the field with the colon <:> and also like to calculate the total time on the form from the inputs. Any one out there that can help please do so. Thanks

whammy
02-02-2003, 05:07 PM
Are you going to be processing this form server-side, or just using javascript?

glenngv
02-03-2003, 12:41 AM
Add appropriate date in the entered time so that it looks like this:


TimeOn = "1/3/2003 8:30 AM"
TimeOff = "1/3/2003 5:30 PM"

Then use Date.parse()

msec = Date.parse(TimeOff)-Date.parse(TimeOn);//milliseconds
//convert msec to desired time unit

I used this in my OT Authorization application (http://www21.brinkster.com/gver/ot/ot.asp) :)