K
K
kuzyairon2020-05-15 22:26:56
PHP
kuzyairon, 2020-05-15 22:26:56

How to add time interval RedBeabPHP?

How to make a time interval in RedBeanPHP for example y + hour or + day or + day?

require "db.php";

$data = $_POST; // Переменная с массивом POST
if (isset($data['do_singup'])) // Преполагает, что кнопка SUMBIT была нажата
    {
          //Здесь происходит регистрация
          $errors = array ();  // переменная ERRORS с массивом
        if ( trim($data['login']) == '') // здесь вписывается логин
                {
                $errors [] = 'Введите логин';
                }
                if( empty($errors))
                {
                    $user = R::dispense('users'); // создание таблицы  USERS
                    $user->login =$data['login']; //Занесение строки user $data переменная  ['login'] - берем из HTML
                    $user ->join_date = date('Y-m-d H:i:s');
                    $user ->expires = date(('Y-m-d H:i:s'));
                    R::isoDateTime($user);
                    R::store($user);


and for some reason in $user ->join_date = date('Ymd H:i:s'); it does not display the correct time, but shifts the time by +3 hours
how to solve this problem correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2020-05-15
@kuzyairon

You just have to plunge into the world of dreams and sadness when working with a date from php.
Create a date through the DateTime class, and manipulate the value through the modify method
And the time is displayed correctly, taking into account the time zone

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question