I’m having troubles to get minute from a string with MINUTE() function, it always gives me 0
$consulta= sprintf("SELECT CURTIME()");
echo $horaActual = $wpdb->get_var( $consulta );
$consulta=sprintf("SELECT HOUR('$horaActual')");
$horaActual= $wpdb->get_var( $consulta );
$consulta=sprintf("SELECT MINUTE('$horaActual')");
$minutosActuales= $wpdb->get_var( $consulta );
22:03:41
0
What is the trouble?
EDIT:
the trouble was the var $horaActual was asigned again in the second query. So the call in the third query was agaist a $horaActual=22 so thats why dosn’t work. Thanks.
You should simplify your SQL by running it in one statement: