PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 29, 2022

[FIXED] Carbon return InvalidArgumentException for a particular format conversion

 January 29, 2022     laravel, laravel-5, php-carbon     No comments   

Issue

I have a date returned from a javascript library in the format 23/10/2019 12:03:46 and while saving in the database i am trying to convert into a carbon object like below:-

 $order->delivery_date =  Carbon::createFromFormat('dd/mm/Y H:i:s',$request->time);

getting error

InvalidArgumentException: Unexpected data found.

also tried these similar links link1 link2 but not able to get out of this problem.


Solution

the format string seems to be wrong. Try it like this:

$order->delivery_date = Carbon::createFromFormat('d/m/Y H:i:s',$request->time);



Answered By - mzolee
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing