the correct way to add hours to a date is this
$startTime = date("Y-m-d H:i:s");
//exibir a hora de início
echo 'Starting Time: '.$startTime;
//adiciona 1 hora ao tempo
$cenvertedTime = date('Y-m-d H:i:s',strtotime('+1 hour',strtotime($startTime)));
//exibir o tempo convertido
echo 'Converted Time (added 1 hour): '.$cenvertedTime;
//adiciona 1 hora e 30 minutos ao horário
$cenvertedTime = date('Y-m-d H:i:s',strtotime('+1 hour +30 minutes',strtotime($startTime)));
//exibir o tempo convertido
echo 'Converted Time (added 1 hour & 30 minutes): '.$cenvertedTime;
//adiciona 1 hora, 30 minutos e 45 segundos ao horário
$cenvertedTime = date('Y-m-d H:i:s',strtotime('+1 hour +30 minutes +45 seconds',strtotime($startTime)));
//exibir o tempo convertido
echo 'Converted Time (added 1 hour, 30 minutes & 45 seconds): '.$cenvertedTime;
//adiciona 1 dia, 1 hora, 30 minutos e 45 segundos ao horário
$cenvertedTime = date('Y-m-d H:i:s',strtotime('+1 day +1 hour +30 minutes +45 seconds',strtotime($startTime)));
//exibir o tempo convertido
echo 'Converted Time (added 1 day, 1 hour, 30 minutes & 45 seconds): '.$cenvertedTime;
I hope with this tutorial you understand how to manipulate your dates and predict the minute and second arrival time day.
follows a time difference calculation function that had ready here:
function timediff($inicio,$fim){
$entrada = $inicio;
$saida = $fim;
$hora1 = explode(":",$entrada);
$hora2 = explode(":",$saida);
$acumulador1 = ($hora1[0] * 3600) + ($hora1[1] * 60) + $hora1[2];
$acumulador2 = ($hora2[0] * 3600) + ($hora2[1] * 60) + $hora2[2];
$resultado = $acumulador2 - $acumulador1;
$hora_ponto = floor($resultado / 3600);
$resultado = $resultado - ($hora_ponto * 3600);
$min_ponto = floor($resultado / 60);
$resultado = $resultado - ($min_ponto * 60);
$secs_ponto = $resultado;
//Grava na variável resultado final
$tempo = $hora_ponto.":".$min_ponto.":".$secs_ponto;
return $tempo;
}
What did you try to do? You checked the PHP date/time functions to see if there’s anything that can help you?
– Woss
Hi Anderson tried more could not
– kibarco net
Could you add in the question your attempt and the obtained result? If you gave error, put the error message.
– Woss
OK doing that
– kibarco net
Put la plus this code works only if the day is today, in case Anderson I think I need to first convert minutes hours into date and then convert into weeks and present ne ?
– kibarco net
So tomorrow, the day after tomorrow and then what you put on?
– user60252
Need presents type arrives Thursday day 08/11/2018 as 17:22 example
– kibarco net