Click to See Complete Forum and Search --> : time


zuzupus
07-07-2003, 07:53 AM
Hi,

is anybody knows how i can get time(system),when i clicks on button(now)
<?
function fillDD($min, $max, $selected)
{
for($i=$min; $i<24; $i++) {
$i = sprintf('%02d', $i);
for($j=$max; $j<60; $j+=5) {
$j = sprintf('%02d', $j);
if($i == $selected && $j == $selected) {
print("<option SELECTED value='$i:$j'>$i:$j</option>\n");
}
else {
print("<option value='$i:$j'>$i:$j</option>\n");
}
}//for($j)
} //for($i)
}

?>
<td>
<select name="time" size="1">
<? fillDD(0, 0, -1); ?>
<input type="button" size="1" name="now">
</select>
</td>
is it possible with PHP that when i click this button i will get system time in this select field

thanks in advance

pyro
07-07-2003, 07:55 AM
Originally posted by zuzupus
is it possible with PHP that when i click this button i will get system time in this select fieldThe only time you can get with PHP is the server time (as it runs server-side). If you want the client time, you will need to use javascript.

zuzupus
07-07-2003, 08:03 AM
thanks so how i can use javascript so that when i click on button system will dispay on select field i can call the function on this button now but it will show soem alert i just want to display in select field when this button is clicked as i have seen some websites they r using button to get present time

var now = new Date();
function a(){
alert(now.getHours()+":"+now.getMinutes()+":"+now.getSeconds());
}

i will really appreciate if you provide the solution

pyro
07-07-2003, 08:13 AM
Answered in the javascript forums: http://forums.webdeveloper.com/showthread.php?s=&postid=66610#post66610