3
InvalidArgumentException: A four digit year could not be found
Data missing in carbon/src/Carbon/Carbon.php:425

Getting this error in my apache logs. What is the cause of this type of error?

David McGregor
  • 132
  • 2
  • 7

2 Answers2

2

Running this on the date first should fix it. Likely getting an invalid date from the front-end.

function validateDate($date, $format = 'Y-m-d H:i:s'){
    $d = DateTime::createFromFormat($format, $date);
    return $d && $d->format($format) == $date;
}

function was copied from this answer or php.net

Glavić
  • 42,781
  • 13
  • 77
  • 107
David McGregor
  • 132
  • 2
  • 7
0

I faced and fixed that problem and problem was that I was using the guard method in the eloquent model and then I was trying to save data using create method. Problem was that the array I was providing to create method as a parameter has an extra column apart from the table's column so somehow our created_at or updated_at field was getting disturbed. Once I fixed the extra column issue. The error was removed.

Yasir Ijaz
  • 674
  • 1
  • 12
  • 19