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

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현