3
My question is the following: I created a function in PHP to check the current date and check the deadline for the end of a contest. Except that the end of this contest will have a specific time, and I don’t know how to limit the date along with the time.
The function is like this:
<?php
function isDateExpired($dateStart, $days){
$timestampNow = strtotime('now');
$timestampExpired = strtotime("+{$days} day", strtotime($dateStart));
return$timestampExpired > $timestampNow) ? true : false;
}
if(isDateExpired('2014-06-09', 1)){
$teste = 'teste testado e testando';
}else{
echo '<script>alert("Concurso encerrado! Aguarde o resultado em breve!");</script>';
echo '<style>#btlike{display:none;}#btshare{display:none;</style>';
}
?>
How can I check the time of the next day? For example, the contest will close at 15hrs of the day 10/06/2014.
Since it will be by hour, you can take the difference between dates by HOURS and put in $timestampExpired = strtotime("+{$hours} hour", strtotime($dateStart));
– mend3
Thanks Victor, thanks a lot!
– Kaleb Figueiredo