DateTime::__construct() expects parameter 1 to be string, object givenmysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or resultConverting string to Date and DateTime__construct() expects parameter 2 to be stringhtmlentities() expects parameter 1 to be string, object givenDateTime::createFromFormat() expects parameter 2 to be string, object givenhtmlentities() expects parameter 1 to be string, object givenInvalid Argument Exception: Data missing when retrieving model via ajax requestChange Date format using CarbonType error: DateTime::__construct() expects parameter 1 to be string, object given in laravelhtmlspecialchars() expects parameter 1 to be string, object given

is it possible to change a material depending on whether it is intersecting with another object?

If every star in the universe except the Sun were destroyed, would we die?

Do aarakocra have arms as well as wings?

Why did Tony's Arc Reactor do this?

The pirate treasure of Leatherback Atoll

Is it unavoidable taking shortcuts in software development sometimes?

Who is the uncredited actor leading the squad in the Valerian movie?

Capacitors with same voltage, same capacitance, same temp, different diameter?

Distance faces never sharp/clear. Too picky?

Yet another calculator problem

Are professors obligated to accept supervisory role? If not, how does it work?

Why do the British opposition parties not want a new election?

Contractor cut joist hangers to make them fit

How to handle fsck "Error while scanning inodes"?

Are personality traits, ideals, bonds, and flaws required?

I multiply the source, you (probably) multiply the output!

How to reference a custom counter that shows section number?

Was Robin Hood's point of view ethically sound?

Can you pop microwave popcorn on a stove?

What makes an ending "happy"?

Are there any space probes or landers which regained communication after being lost?

Stack class in Java8

How can I return only the number of paired values in array?

I need to know information from an old German birth certificate



DateTime::__construct() expects parameter 1 to be string, object given


mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or resultConverting string to Date and DateTime__construct() expects parameter 2 to be stringhtmlentities() expects parameter 1 to be string, object givenDateTime::createFromFormat() expects parameter 2 to be string, object givenhtmlentities() expects parameter 1 to be string, object givenInvalid Argument Exception: Data missing when retrieving model via ajax requestChange Date format using CarbonType error: DateTime::__construct() expects parameter 1 to be string, object given in laravelhtmlspecialchars() expects parameter 1 to be string, object given






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to get two date calculation . when i placed



$from = Carbon::createFromFormat('m-d-Y H:i:s', '02-10-2017 10:02:20');


code i get value but when i placed data from mysql



$from = Carbon::createFromFormat('m-d-Y H:i:s', $from_date); 


can not find data, and can not calculation to and from date



Controller.php



public function circulerMatchView()

$user_id = Auth::user()->id;

$resume_exp = Experience::select('user_exp_keyword')
->where('user_id','=',$user_id)
->get();
$from_date = Experience::selectRaw('exp_from_date')
->where('user_id','=',$user_id)
->orderBy('exp_from_date','desc')
->take(1)
->get();
$to_date = Experience::selectRaw('exp_to_date')
->where('user_id','=',$user_id)
->orderBy('exp_from_date','desc')
->take(1)
->get();

$from = DateTime::createFromFormat('m-d-Y H:i:s', $from_date);
$to = Carbon::createFromFormat('m-d-Y H:i:s', $to_date);
$realAge = Carbon::parse($to)->diff(Carbon::parse($from))->format('%y');
print_r($realAge);



if $from_date is 02-21-2017 and $to_date is 02-21-2018



result is 1 year










share|improve this question
































    0















    I am trying to get two date calculation . when i placed



    $from = Carbon::createFromFormat('m-d-Y H:i:s', '02-10-2017 10:02:20');


    code i get value but when i placed data from mysql



    $from = Carbon::createFromFormat('m-d-Y H:i:s', $from_date); 


    can not find data, and can not calculation to and from date



    Controller.php



    public function circulerMatchView()

    $user_id = Auth::user()->id;

    $resume_exp = Experience::select('user_exp_keyword')
    ->where('user_id','=',$user_id)
    ->get();
    $from_date = Experience::selectRaw('exp_from_date')
    ->where('user_id','=',$user_id)
    ->orderBy('exp_from_date','desc')
    ->take(1)
    ->get();
    $to_date = Experience::selectRaw('exp_to_date')
    ->where('user_id','=',$user_id)
    ->orderBy('exp_from_date','desc')
    ->take(1)
    ->get();

    $from = DateTime::createFromFormat('m-d-Y H:i:s', $from_date);
    $to = Carbon::createFromFormat('m-d-Y H:i:s', $to_date);
    $realAge = Carbon::parse($to)->diff(Carbon::parse($from))->format('%y');
    print_r($realAge);



    if $from_date is 02-21-2017 and $to_date is 02-21-2018



    result is 1 year










    share|improve this question




























      0












      0








      0








      I am trying to get two date calculation . when i placed



      $from = Carbon::createFromFormat('m-d-Y H:i:s', '02-10-2017 10:02:20');


      code i get value but when i placed data from mysql



      $from = Carbon::createFromFormat('m-d-Y H:i:s', $from_date); 


      can not find data, and can not calculation to and from date



      Controller.php



      public function circulerMatchView()

      $user_id = Auth::user()->id;

      $resume_exp = Experience::select('user_exp_keyword')
      ->where('user_id','=',$user_id)
      ->get();
      $from_date = Experience::selectRaw('exp_from_date')
      ->where('user_id','=',$user_id)
      ->orderBy('exp_from_date','desc')
      ->take(1)
      ->get();
      $to_date = Experience::selectRaw('exp_to_date')
      ->where('user_id','=',$user_id)
      ->orderBy('exp_from_date','desc')
      ->take(1)
      ->get();

      $from = DateTime::createFromFormat('m-d-Y H:i:s', $from_date);
      $to = Carbon::createFromFormat('m-d-Y H:i:s', $to_date);
      $realAge = Carbon::parse($to)->diff(Carbon::parse($from))->format('%y');
      print_r($realAge);



      if $from_date is 02-21-2017 and $to_date is 02-21-2018



      result is 1 year










      share|improve this question
















      I am trying to get two date calculation . when i placed



      $from = Carbon::createFromFormat('m-d-Y H:i:s', '02-10-2017 10:02:20');


      code i get value but when i placed data from mysql



      $from = Carbon::createFromFormat('m-d-Y H:i:s', $from_date); 


      can not find data, and can not calculation to and from date



      Controller.php



      public function circulerMatchView()

      $user_id = Auth::user()->id;

      $resume_exp = Experience::select('user_exp_keyword')
      ->where('user_id','=',$user_id)
      ->get();
      $from_date = Experience::selectRaw('exp_from_date')
      ->where('user_id','=',$user_id)
      ->orderBy('exp_from_date','desc')
      ->take(1)
      ->get();
      $to_date = Experience::selectRaw('exp_to_date')
      ->where('user_id','=',$user_id)
      ->orderBy('exp_from_date','desc')
      ->take(1)
      ->get();

      $from = DateTime::createFromFormat('m-d-Y H:i:s', $from_date);
      $to = Carbon::createFromFormat('m-d-Y H:i:s', $to_date);
      $realAge = Carbon::parse($to)->diff(Carbon::parse($from))->format('%y');
      print_r($realAge);



      if $from_date is 02-21-2017 and $to_date is 02-21-2018



      result is 1 year







      php laravel eloquent datetimepicker difference






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 21 at 13:57









      Rahul

      14.2k6 gold badges25 silver badges47 bronze badges




      14.2k6 gold badges25 silver badges47 bronze badges










      asked Mar 28 at 7:37









      Iqramol HaqueIqramol Haque

      32 bronze badges




      32 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          You are fetching array by using get. Replace these two lines with your codes and check. It will fetch only field data values.



          $from_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_from_date','desc')
          ->take(1)
          ->pluck('exp_from_date')[0];
          $to_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_to_date','desc')
          ->take(1)
          ->pluck('exp_to_date')[0];


          Once check this documentation for details about pluck.






          share|improve this answer



























          • now answer is 1 second before, this is not correct answer

            – Iqramol Haque
            Mar 28 at 13:07












          • Are you getting from_date and to_date? will you post here?

            – Rahul
            Mar 28 at 14:08










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392319%2fdatetime-construct-expects-parameter-1-to-be-string-object-given%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0
















          You are fetching array by using get. Replace these two lines with your codes and check. It will fetch only field data values.



          $from_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_from_date','desc')
          ->take(1)
          ->pluck('exp_from_date')[0];
          $to_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_to_date','desc')
          ->take(1)
          ->pluck('exp_to_date')[0];


          Once check this documentation for details about pluck.






          share|improve this answer



























          • now answer is 1 second before, this is not correct answer

            – Iqramol Haque
            Mar 28 at 13:07












          • Are you getting from_date and to_date? will you post here?

            – Rahul
            Mar 28 at 14:08















          0
















          You are fetching array by using get. Replace these two lines with your codes and check. It will fetch only field data values.



          $from_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_from_date','desc')
          ->take(1)
          ->pluck('exp_from_date')[0];
          $to_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_to_date','desc')
          ->take(1)
          ->pluck('exp_to_date')[0];


          Once check this documentation for details about pluck.






          share|improve this answer



























          • now answer is 1 second before, this is not correct answer

            – Iqramol Haque
            Mar 28 at 13:07












          • Are you getting from_date and to_date? will you post here?

            – Rahul
            Mar 28 at 14:08













          0














          0










          0









          You are fetching array by using get. Replace these two lines with your codes and check. It will fetch only field data values.



          $from_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_from_date','desc')
          ->take(1)
          ->pluck('exp_from_date')[0];
          $to_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_to_date','desc')
          ->take(1)
          ->pluck('exp_to_date')[0];


          Once check this documentation for details about pluck.






          share|improve this answer















          You are fetching array by using get. Replace these two lines with your codes and check. It will fetch only field data values.



          $from_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_from_date','desc')
          ->take(1)
          ->pluck('exp_from_date')[0];
          $to_date = Experience::
          where('user_id','=',$user_id)
          ->orderBy('exp_to_date','desc')
          ->take(1)
          ->pluck('exp_to_date')[0];


          Once check this documentation for details about pluck.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 28 at 13:25

























          answered Mar 28 at 7:39









          RahulRahul

          14.2k6 gold badges25 silver badges47 bronze badges




          14.2k6 gold badges25 silver badges47 bronze badges















          • now answer is 1 second before, this is not correct answer

            – Iqramol Haque
            Mar 28 at 13:07












          • Are you getting from_date and to_date? will you post here?

            – Rahul
            Mar 28 at 14:08

















          • now answer is 1 second before, this is not correct answer

            – Iqramol Haque
            Mar 28 at 13:07












          • Are you getting from_date and to_date? will you post here?

            – Rahul
            Mar 28 at 14:08
















          now answer is 1 second before, this is not correct answer

          – Iqramol Haque
          Mar 28 at 13:07






          now answer is 1 second before, this is not correct answer

          – Iqramol Haque
          Mar 28 at 13:07














          Are you getting from_date and to_date? will you post here?

          – Rahul
          Mar 28 at 14:08





          Are you getting from_date and to_date? will you post here?

          – Rahul
          Mar 28 at 14:08








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392319%2fdatetime-construct-expects-parameter-1-to-be-string-object-given%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript