Check if date and hour / minute have already expired

-1

I am having a problem, when uploading my website to PHP 5.6 the code I use to check if such date and such time / minute has expired is simply not respecting the time, if it is the date already speaks that expired without checking the hour / minute. Does anyone have a solution?

$sql = "SELECT * FROM noticias WHERE programada = 'sim'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res)>0){
$row = mysql_fetch_array($res);

function NoticiasProgramadas($data){
    $dt_expira = str_replace("/", "-", $data);
    $dateInicio = date('Y/m/d G:i:s', strtotime($dt_expira));
    $timestamp_dt_expira = strtotime($dt_expira);
    $dt_atual = date("Y/m/d G:i:s");
    $timestamp_dt_atual = strtotime($dt_atual);

        $ret = '';
        if ($timestamp_dt_atual >= $timestamp_dt_expira) {
            $ret = "exp";
        }
    return $ret;
}
$d = NoticiasProgramadas("$row[postdate] $row[posthora]");
if ($d == "exp"){

//executa um código mysql

}
    
asked by anonymous 11.04.2018 / 22:25

1 answer

1

Friend,

Check how the timezone of your server is online, in some cases before doing anything in PHP, you should set your timezone so that from then on your PHP works only with exact date and time, for example: / p>

<?php
date_default_timezone_set('America/Sao_Paulo');

// daqui em diante tu bota o seu código...
    
12.04.2018 / 14:41