0
I’m having a problem, when I upload my site to PHP 5.6 the code I use to check if such a date and such an hour/minute expired is simply not respecting the time, if it is the date already says that expired without checking the hour/minute. Does anyone have any 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
}
Echo in the variables
$timestamp_dt_atual
and$timestamp_dt_expira
to see how they are before the if;– David Dias
11-04-2018, 18:19 2018/04/11 23:19:01
– user89739
No, the same timestamp, before the
if ($timestamp_dt_atual >= $timestamp_dt_expira)
– David Dias
Sorry, they’re like 1523440560 1523483518
– user89739
Can you simplify our life by editing your question with the data you are using to test? Type what is
$data
, so we can test your code and help– David Dias
The $date has nothing
– user89739
Forgiveness, that:
$row[postdate] $row[posthora]
– David Dias
It comes from the first code on top of the $sql = "SELECT * FROM WHERE newsprogrammed = 'yes'";
– user89739
Let’s go continue this discussion in chat.
– David Dias