Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $hora="21:30";
- //declaracion variables
- //codigo: Crearemos dos objetos fecha,
- // una la actual y otra a la medianoche
- //Luego las restaremos para ver la diferencia
- $fecha1=new DateTime('2019-12-31 '.$hora);
- $fecha2=date_create('2020-01-01 00:00:00');
- $diferencia = $fecha2->diff($fecha1);
- //$diferencia = date_diff($fecha2, $fecha1);
- $horas=$diferencia->h;
- $minutos=$diferencia->i;
- $queda = $horas * 60 + $minutos;
- echo "Para la medianoche quedan: " . $queda;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement