Skywalskurt
1 week ago

Laravel 5.8 - Carbon / unexpected data found. unexpected data found

Posted 1 week ago by Skywalskurt

Hello,

I'm developing a Laravel application (version 5.8) and i have some issues with the createFromFormat Carbon's method in Internet Explorer 11 (yeah, i know... but this is the default browser of my company).

Here is the piece of code where i got the error and the stack trace of the error :

$datas['DT_DELIB'] = Carbon::createFromFormat('d/m/Y',$delibProjRequest->DT_DELIB)->toDateTimeString();
InvalidArgumentException 
Unexpected data found. Unexpected data found. Unexpected data found.
InvalidArgumentException thrown with message "Unexpected data found.
Unexpected data found.
Unexpected data found."

Stacktrace:
#56 InvalidArgumentException in C:\laragon\www\projetMecenat\vendor\nesbot\carbon\src\Carbon\Traits\Creator.php:623
#55 Carbon\Carbon:rawCreateFromFormat in C:\laragon\www\projetMecenat\vendor\nesbot\carbon\src\Carbon\Traits\Creator.php:645
#54 Carbon\Carbon:createFromFormat in C:\laragon\www\projetMecenat\app\Http\Controllers\DeliberationProjetController.php:50
#53 App\Http\Controllers\DeliberationProjetController:store in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Controller.php:54
#52 call_user_func_array in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Controller.php:54
#51 Illuminate\Routing\Controller:callAction in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php:45
#50 Illuminate\Routing\ControllerDispatcher:dispatch in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Route.php:219
#49 Illuminate\Routing\Route:runController in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Route.php:176
#48 Illuminate\Routing\Route:run in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Router.php:680
#47 Illuminate\Routing\Router:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:30
#46 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php:41
#45 Illuminate\Routing\Middleware\SubstituteBindings:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#44 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#43 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php:75
#42 Illuminate\Foundation\Http\Middleware\VerifyCsrfToken:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#41 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#40 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php:49
#39 Illuminate\View\Middleware\ShareErrorsFromSession:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#38 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#37 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php:56
#36 Illuminate\Session\Middleware\StartSession:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#35 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#34 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php:37
#33 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#32 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#31 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php:66
#30 Illuminate\Cookie\Middleware\EncryptCookies:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#29 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#28 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:104
#27 Illuminate\Pipeline\Pipeline:then in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Router.php:682
#26 Illuminate\Routing\Router:runRouteWithinStack in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Router.php:657
#25 Illuminate\Routing\Router:runRoute in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Router.php:623
#24 Illuminate\Routing\Router:dispatchToRoute in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Router.php:612
#23 Illuminate\Routing\Router:dispatch in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:176
#22 Illuminate\Foundation\Http\Kernel:Illuminate\Foundation\Http\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:30
#21 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php:65
#20 Barryvdh\Debugbar\Middleware\InjectDebugbar:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#19 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#18 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:21
#17 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#16 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#15 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:21
#14 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#13 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#12 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php:27
#11 Illuminate\Foundation\Http\Middleware\ValidatePostSize:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#10 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#9 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php:62
#8 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#7 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#6 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\fideloper\proxy\src\TrustProxies.php:57
#5 Fideloper\Proxy\TrustProxies:handle in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
#4 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
#3 Illuminate\Routing\Pipeline:Illuminate\Routing\{closure} in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:104
#2 Illuminate\Pipeline\Pipeline:then in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:151
#1 Illuminate\Foundation\Http\Kernel:sendRequestThroughRouter in C:\laragon\www\projetMecenat\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:116
#0 Illuminate\Foundation\Http\Kernel:handle in C:\laragon\www\projetMecenat\public\index.php:55

And when i dump the data passed in parameter i got (in IE and others browser) :

dd($delibProjRequest->DT_DELIB);
// "‎21‎/‎07‎/‎2020"

The strange thing is when i try with a date that have the same format, it seems to work :

$test = Carbon::createFromFormat("d/m/Y",'20/07/2019');
dd($test);
/**
Carbon\Carbon @1563608837 {#405 ▼
  #constructedObjectId: "000000006b8ef720000000002bcf1ddf"
  #localMonthsOverflow: null
  #localYearsOverflow: null
  #localStrictModeEnabled: null
  #localHumanDiffOptions: null
  #localToStringFormat: null
  #localSerializer: null
  #localMacros: null
  #localGenericMacros: null
  #localFormatFunction: null
  #localTranslator: null
  #dumpProperties: array:3 [▶]
  #dumpLocale: null
  date: 2019-07-20 07:47:17.0 UTC (+00:00)
  timezone_type: 3
  timezone: "UTC"
*/

I think that this is something particular with IE 11 because it works fine in others browsers. If someone got an idea or clues to help it will be great, i'm a bit stuck right now...

Thanks in advance.

Please sign in or create an account to participate in this conversation.