Show date and time to current user

Asked

Viewed 34 times

0

I have this code:

while($rows_cursos = mysqli_fetch_array($resultado_cursos)) {

$tabela1 .= '<td> <input type="date" name= "Data[]" id= "Data" value="<?php echo date("Y-m-d");?> <input type="time" required="" id="Hora" name="Hora[]" value="<?php echo date("H:i:s");?></td>';
}

But neither shows the current date nor the current time as shown in the image:

inserir a descrição da imagem aqui

  • The problem is in the quotes: value="<?php echo date("H:i:s");?> put it like this value="<?php echo date(\"H:i:s\");?>"

1 answer

3


You must concatenate:

$tabela1 .= '<td> <input type="date" name= "Data[]" id= "Data" value="'. date("Y-m-d") .'"> <input type="time" required="" id="Hora" name="Hora[]" value="' . date("H:i:s") . '"></td>';
  • It worked. Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.