This is close.  When I enter 6:45:00 and 7:00:00 I get 1:45 instead of 15.

Thanks 

-----Original Message-----
From: BILLY CRAVENS [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 15, 2001 4:53 PM
To: [EMAIL PROTECTED]
Subject: Re:


I'm sure there's a much cleaner way of doing it, but how about manipulating
your times as string objects, splitting them into arrays subtracting
elements?

Some messy code that needs a lot of error checking, etc:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <title>Untitled</title>
 <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    function getDiff() {
  tempTime1 = document.frm.time1.value;
  var strTime1 = tempTime1.toString();
  tempTime2 = document.frm.time2.value;
  var strTime2 = tempTime2.toString();
  a1 = strTime1.split(":");
  a2 = strTime2.split(":");
  h = parseInt(a2[0]) - parseInt(a1[0]);
  m = parseInt(a2[1]) - parseInt(a1[1]);
  s = parseInt(a2[2]) - parseInt(a1[2]);
  alert (h + ":" + m + ":" + s);
 }
    //-->
    </SCRIPT>
</head>
<body>
<form name="frm">
 start: <input type="text" name="time1">
 end: <input type="text" name="time2">
 <input type="button" value="get difference" onClick="getDiff()">
</form>
</body>
</html>


----- Original Message -----
From: "Schreck, Tom" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 15, 2001 4:39 PM


> I've a user interface where the user selects 2 different times and need to
> be able to calculate the time difference on the client using javascript.
> The time is generated using CF's TimeFormat:
> TimeFormat(DateAdd("n",15,variables.StartTime),'hh:mm:sstt');  So, when
the
> JavaScript function is called, it receives 2 different values, for
instance,
> 06:15:00 and 06:45:00.  I need to calculate the dufference, 30.  Any
> suggestions would be appreciated.  Do I need to modify the time values to
> include the date, or military time.  Not concerned about calculations
> involving days, just time.
>
> Tom Schreck
> [EMAIL PROTECTED]
> 817-252-4900
>
> I have not failed. I've just found 10,000 ways that won't work.
> - Thomas Edison
>
>
>
> -------------------------------------------------------------------------
> This email server is running an evaluation copy of the MailShield anti-
> spam software. Please contact your email administrator if you have any
> questions about this message. MailShield product info: www.mailshield.com
>
> -----------------------------------------------
> To post, send email to [EMAIL PROTECTED]
> To subscribe / unsubscribe: http://www.dfwcfug.org
>

-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

Reply via email to