This topic is locked

Disable adding records up to a date/time

5/11/2023 2:14:55 AM
PHPRunner General questions
A
alfonso authorDevClub member

I need a form to be disabled until an hour on a given day. Records cannot be added and an informing message appears. Is it possible in phprunner? Thank you

Sergey Kornilov admin 5/11/2023

Possible. Use an event like BeforeProcess of the Add page. Check the time there and redirect user somewhere or display a message instead of the Add page if no data is allowed to be added.

A
alfonso authorDevClub member 5/11/2023

I use:
date_default_timezone_set('Europe/Madrid');
$fechaObjetivo = strtotime('2023-05-11 16:52:00');
`$fechaActual = time();

if ($fechaActual < $fechaObjetivo) {
echo "La fecha actual es anterior al " . date('Y-m-d H:i:s', $fechaObjetivo);
echo "La fecha actual es: " . date('Y-m-d H:i:s', $fechaActual);
exit();
}`