Welcome Guest, Not a member yet? Register   Sign In
DateTime::createFromFormat(): Passing null to parameter #2 ($datetime) of type string
#1

I got error message:
DateTime::createFromFormat(): Passing null to parameter #2 ($datetime) of type string
this error is show up when using filter: '

PHP Code:
'birth_date' => 'valid_date[d/m/Y]'

is this bugI'm using PHP: 8.1.2 — CodeIgniter: 4.1.9. 
Reply
#2

I don't know. How to reproduce?
Reply
#3

(03-14-2022, 06:36 PM)kenjis Wrote: I don't know. How to reproduce?

i just make a validation filter like this :

'birth_date' => 'valid_date[d/m/Y]'
Reply
#4
Photo 

Here's detail of the error because of it: https://ibb.co/LZVjKZR
Reply
#5

(This post was last modified: 03-15-2022, 10:24 PM by kenjis.)

Can't reproduce it.


PHP Code:
<?php

namespace App\Controllers;

class 
Home extends BaseController
{
    public function index()
    {
        if ($this->validate([
            'birth_date' => 'valid_date[d/m/Y]',
        ])) {
            return 'OK';
        } else {
            return $this->validator->getError();
        }
    }


Code:
$ php -v
PHP 8.1.2 (cli) (built: Jan 21 2022 04:46:45) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

I was able to reproduce. If I don't send the field, the ErrorException occurs.

I sent a PR https://github.com/codeigniter4/CodeIgniter4/pull/5804
Reply
#6

Thanks, I will use your code as a solution for my problem until it gets patched?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB