2
Every year I have two problems, one when the summer schedule starts and the other when it ends.
Anyway, yesterday the clock was delayed by an hour that created a giant problem.
The page should allow the user to access it only with a time interval, in this case of 10 minutes.
For this is done the following:
Imagine:
<?
// $data = date('Y-m-d H:i:s');
$data = '2016-02-20 23:50:00';
$mysqli->query("SELECT null FROM tabela WHERE Data >= '$data' AND User = '1")
if($mysqli->num_rows <= 0){
$dataProxima = date('Y-m-d H:i:s', strtotime("+10 minutes");
$mysqli->query("INSERT INTO tabela VALUES (0, '$dataProxima', '1')");
// Isso irá permitir que o usuário somente entre na página depois de 10 minutos.
echo 'ok';
// Pagina é carregada
}else{
// echo 'falhou';
header('location: meusite.com');
exit;
}
?>
In the table exists:
id | Data | User
1 | 2016-02-20 23:39:00 | 1
In this example you will return:
ok
Theoretically if there is no date greater than the current date will continue, if it will not fail.
But...
When the summer time is over you will automatically return to 2016-02-20 23:00:00
, with it will fail, even if in theory has already exceeded the date.
Now, after the release time, the information will be:
$data = '2016-02-20 23:00:00';
// Irá retornar: falhou
Is there any correction that can be made directly to fix these situations?
You still have a bigger problem!
If the bank’s data is:
id | Data
1 | 2016-02-21 00:01:00
You will have to wait again an hour to return "ok", instead of a minute.
Have any Mysql function that compensates for this summer time difference using DATETIME
?
Yes, that’s the problem. But I can’t find a solution so it doesn’t happen. The only solution, that I can think of, would be to never use the summer time and then inform visually to the user based on the version time, or not, when necessary.
– Inkeliz
Wouldn’t it be enough to increase or decrease an hour? For example, daylight saving time entered, decreasing 1 hour at the time of comparison, but keeps the original dates and times ignoring daylight saving time.
– Daniel Omine