There is a task: to limit the storage time, the restriction is chosen by the user.
Nr: 2 inputa, in one we write a number, and in another we select the type of storage from the dropdown list
2 | hours (minutes, days, week)
Task with storage for several days and weeks did.
but how to do 1 and 2? How to make storage for several hours / minutes?
Here is how I did the storage days
Where
$row_c['load_date'] - время загрузки файла. $current_d - нынешнее время. $row_c['time_save'] - время хранения выбранное пользователем. >
$count_date = $row_c['load_date'] - $current_d; $difference = intval(abs(strtotime($row_c['load_date']) - strtotime($current_d))); // Количество дней $finish_c_d = (int)$int_count_date = $difference / (3600 * 24); // Проверка и удаление // Проверка дней if ($finish_c_d > $row_c['time_save']) { echo "время истекло, данные удалились! id= ".$row_c['id']; }else{echo "Рано удалять! id= ".$row_c['id'];} }
mysqlit would be like this:select * from table_name where time_delete > now()to get available,select * from table_name where time_delete <= now()to get obsolete. Because Since we no longer work with hours / minutes, etc., but we work with one time, we can add any interval of any kind (at least 55 seconds, at least two years and 10 days). Something like this. - BOPOH