Click to See Complete Forum and Search --> : timedifference between 2 clocks


zuzupus
06-13-2003, 09:39 AM
Hi.

I created two Fields which showing time
One field is From which is combo so that use can select
the time and another field To is Clock as in PHP wont refresh clock so i used javascript for that. another field is to get the time difference beiween these two fields.

anybody knows how to calculate the time difference which will show automatically in third field,i mean to say i dont have to click in any of from and to fields.

<
function fillDD($min, $max, $selected)
{
for($i=$min; $i<24; $i++)
{
for($j=$max; $j<60; $j+=5)
{
if($i == $selected && $j == $selected)
{
if ($i < 10) {
print("<option SELECTED value='$i:$j'>0$i:$j</option>\n");
} else {
print("<option SELECTED value='$i:$j'>$i:$j</option>\n");
}
}
else
{
if ($i < 10) {
print("<option value='$i:$j'>0$i:$j</option>\n");
} else {
print("<option value='$i:$j'>$i:$j</option>\n");
}
}
}//for($j)
} //for($i)
}
From:
<select name="From" size="1" onFocus="calculateIst()">
<option selected value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>
<? fillDD(8, 0, -1); ?>
</select>
To:
<input type="text" size="2" class="button" name="bis" readonly>
<input size="1" class="button" type="text" value="0" name="Time Diff" readonly></td>

<SCRIPT language="JavaScript">
function show(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()

if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
document.tstest.bis.value=hours+":"+minutes
setTimeout("show()",1000)
}
show()
</script>



How i can get the time diff. in 3rd field without clicking on any of the fields is it possible,if not then what to do :(

thanks in advance

zuzupus

pyro
06-15-2003, 05:45 PM
What exactly are you trying to do? It would help if you explain what you need better. Try looking into mktime (http://us2.php.net/manual/en/function.mktime.php). This will give you a Unix timestamp, which is easily compared...