Ik ben met een timer bezig die momenteel werkt. Alleen wil ik nog wat aan het uiterlijk van de timer doen. Dan heb ik het met name over een 0 die erbij moet.
Dit is het script momenteel:
Daarna laat ik de timer zien met
Dit werkt helemaal top. Maar als ik nu de timer heb en zet de tijd bijvoorbeeld op 59 seconden dan staat er dit: 0
59 Ik wil echter dit: 0:00:59
Of bijvoorbeeld 1 minuut 59 --> 0:1:59 Hiervan wil ik dus 0:01:59
Ik hoop dat ik mijn probleem goed heb uitgelegd en dat iemand het antwoord weet
Dit is het script momenteel:
// eerst halen we alle tijden op en berekenen allerlij dingen
$gettimes1 = mysql_query("SELECT * FROM bouwtijden WHERE username = ".$_SESSION[username]." AND bouw_id = 1 AND map_id = ".$_GET[map_id]."");
$rowtimes1 = mysql_fetch_assoc($gettimes1);
$numtimes1 = mysql_num_rows($gettimes1);
$targetYear1 = substr($rowtimes1[time_later],0,4);
$targetMonth1 = substr($rowtimes1[time_later],5,2);
$targetDay1 = substr($rowtimes1[time_later],8,2);
$targetHour1 = substr($rowtimes1[time_later],11,2);
$targetMinute1 = substr($rowtimes1[time_later],14,2);
$targetSecond1 = substr($rowtimes1[time_later],17,2);
$dateFormat1 = "Y-m-d H:i:s";
$targetDate1 = mktime($targetHour1,$targetMinute1,$targetSecond1,$targetMonth1,$targetDay1,$targetYear1);
$actualDate1 = time();
$secondsDiff1 = $targetDate1 - $actualDate1;
$remainingDay1 = floor($secondsDiff1/60/60/24);
$remainingHour1 = floor(($secondsDiff1-($remainingDay1*60*60*24))/60/60);
$remainingMinutes1 = floor(($secondsDiff1-($remainingDay1*60*60*24)-($remainingHour1*60*60))/60);
$remainingSeconds1 = floor(($secondsDiff1-($remainingDay1*60*60*24)-($remainingHour1*60*60))-($remainingMinutes1*60))
$targetDateDisplay1 = date($dateFormat1,$targetDate1);
$actualDateDisplay1 = date($dateFormat1,$actualDate1);
<script type="text/javascript">
var function1 = 0;
</script>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$numtimes1[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
{[/COLOR]
?>
<script type="text/javascript">
function1 = 1;
</script>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?>
<script type="text/javascript">
function loadFunctions ()
{
if(function1 == 1)
{
setCountDown1();
}
}
var days1 = [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$remainingDay1[/COLOR][COLOR= #007700];[/COLOR] ?>
var hours1 = [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$remainingHour1[/COLOR][COLOR= #007700];[/COLOR] ?>
var minutes1 = [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$remainingMinutes1[/COLOR][COLOR= #007700];[/COLOR] ?>
var seconds1 = [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$remainingSeconds1[/COLOR][COLOR= #007700];[/COLOR] ?>
function setCountDown1 ()
{
if(seconds1 == 0 && minutes1 == 0 && hours1 == 0)
{
}
else
{
seconds1--;
}
if (seconds1 < 0)
{
minutes1--;
seconds1 = 59
}
if (minutes1 < 0)
{
hours1--;
minutes1 = 59
}
if (hours1 < 0)
{
days1--;
hours1 = 23
}
document.getElementById("remain1").innerHTML = ""+hours1+":"+minutes1+":"+seconds1+"";
setTimeout ( "setCountDown1()", 1000 );
} Daarna laat ik de timer zien met
Dit werkt helemaal top. Maar als ik nu de timer heb en zet de tijd bijvoorbeeld op 59 seconden dan staat er dit: 0
59 Ik wil echter dit: 0:00:59Of bijvoorbeeld 1 minuut 59 --> 0:1:59 Hiervan wil ik dus 0:01:59
Ik hoop dat ik mijn probleem goed heb uitgelegd en dat iemand het antwoord weet

