3
I have the following php function below:
function showComboHorarios($name, $default = '08:00') {
$hi = 6; // hora inicial
$hf = 23; // hora final
?>
<select style="width: 80px;" name="<?php echo $name; ?>">
<?php
for ($i = $hi; $i <= $hf; $i++) {
$h = ($i < 10) ? '0' . $i : $i;
$h .= ':';
?>
<option value="<?php echo $h . '00'; ?>"<?php echo ($default == $h . '00') ? ' selected' : ''; ?>><?php echo $h . '00'; ?></option>
<option value="<?php echo $h . '30'; ?>"<?php echo ($default == $h . '30') ? ' selected' : ''; ?>><?php echo $h . '30'; ?></option>
<?php
}
?>
</select>
<?php
}
and then displays the screen:
However, I am trying to insert a for minute a minute in this same function:
function showComboHorarios($name, $default = '08:00') {
$hi = 6; // hora inicial
$hf = 23; // hora final
?>
<select style="width: 80px;" name="<?php echo $name; ?>">
<?php
for ($i = $hi; $i <= $hf; $i++) {
$h = ($i < 10) ? '0' . $i : $i;
$h .= ':';
for ($min = 0; $min< 59; $min++){
?>
<option value="<?php echo $h . $min ?>"<?php echo ($default == $h . $min ) ? ' selected' : ''; ?>><?php echo $h . $min ?></option>
<option value="<?php echo $h . $min ?>"<?php echo ($default == $h . $min) ? ' selected' : ''; ?>><?php echo $h . $min; ?></option>
<?php
}//for mminuto
}
?>
</select>
<?php
}
however, on the screen displays like this:
As I leave in the format 00:00 ?
grateful for the attention.
thanks, worked using sprintf function
– hulckb