PHP Fatal error: Call to a member function format() on booleanFatal error: Call to a member function format () on booleanInserting dates into an SQL database using PHPPHP DateTime: Call to a member function format() on booleanPHP Fatal Error Call to a member function format() on booleanCall to a member function format() on boolean in PHP LARAVELHow do I catch a PHP Fatal ErrorstartsWith() and endsWith() functions in PHPHow can I get useful error messages in PHP?How do I get PHP errors to display?Reference — What does this symbol mean in PHP?Reference - What does this error mean in PHP?Why shouldn't I use mysql_* functions in PHP?PHP Fatal Error Call to a member function format() on booleanFatal error: Uncaught Error: Call to a member function format() on booleanFatal error: Call to a member function format () on boolean

I need to know information from an old German birth certificate

Why can't some airports handle heavy aircraft while others do it easily (same runway length)?

How to finish my PhD?

Do aarakocra have arms as well as wings?

Why does 8 bit truecolor use only 2 bits for blue?

Project Euler problem #112

What is the purpose of the rotating plate in front of the lock?

Why does low tire pressure decrease fuel economy?

Bacteria vats to generate edible biomass, require intermediary species?

How do English-speaking kids loudly request something?

Complex conjugate and transpose "with respect to a basis"

Would a character take damage when surrounded by, but not in, flames?

How do we create our own symbolisms?

Furthest distance half the diameter?

Problem with listing a directory to grep

How can I hint that my character isn't real?

Infinitely many primes

Do you need to burn fuel between gravity assists?

What can we do about our 9-month-old putting fingers down his throat?

Python implementation of atoi

How can electricity be positive when electrons are negative?

How to run NPCs with complicated mechanics?

Why does PAUSE key have a long make code and no break code?

How invisible hand adjusts stock prices if company is listed on multiple exchanges, under multiple currencies, and one of the currencies plunges?



PHP Fatal error: Call to a member function format() on boolean


Fatal error: Call to a member function format () on booleanInserting dates into an SQL database using PHPPHP DateTime: Call to a member function format() on booleanPHP Fatal Error Call to a member function format() on booleanCall to a member function format() on boolean in PHP LARAVELHow do I catch a PHP Fatal ErrorstartsWith() and endsWith() functions in PHPHow can I get useful error messages in PHP?How do I get PHP errors to display?Reference — What does this symbol mean in PHP?Reference - What does this error mean in PHP?Why shouldn't I use mysql_* functions in PHP?PHP Fatal Error Call to a member function format() on booleanFatal error: Uncaught Error: Call to a member function format() on booleanFatal error: Call to a member function format () on boolean






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








16















Crashes on:



<?php 
$date = "13-06-2015 23:45:52";
echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s');
?>



PHP Fatal error: Call to a member function format() on boolean




But with other dates works well:



<?php 
$date = "10.06.2015 09:25:52";
echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s');
?>


Wrong format?










share|improve this question


























  • Neither one actually work

    – John Conde
    Jun 10 '15 at 0:07











  • $date = "10.06.2015 09:25:52"; echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s'); -works

    – user1539207
    Jun 10 '15 at 0:08












  • $date = "13-06-2015 23:45:52"; echo Datetime::createFromFormat('d-m-Y h:i:s',$date )->format('Y-m-d h:i:s'); - no working anyway

    – user1539207
    Jun 10 '15 at 0:09


















16















Crashes on:



<?php 
$date = "13-06-2015 23:45:52";
echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s');
?>



PHP Fatal error: Call to a member function format() on boolean




But with other dates works well:



<?php 
$date = "10.06.2015 09:25:52";
echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s');
?>


Wrong format?










share|improve this question


























  • Neither one actually work

    – John Conde
    Jun 10 '15 at 0:07











  • $date = "10.06.2015 09:25:52"; echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s'); -works

    – user1539207
    Jun 10 '15 at 0:08












  • $date = "13-06-2015 23:45:52"; echo Datetime::createFromFormat('d-m-Y h:i:s',$date )->format('Y-m-d h:i:s'); - no working anyway

    – user1539207
    Jun 10 '15 at 0:09














16












16








16


2






Crashes on:



<?php 
$date = "13-06-2015 23:45:52";
echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s');
?>



PHP Fatal error: Call to a member function format() on boolean




But with other dates works well:



<?php 
$date = "10.06.2015 09:25:52";
echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s');
?>


Wrong format?










share|improve this question
















Crashes on:



<?php 
$date = "13-06-2015 23:45:52";
echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s');
?>



PHP Fatal error: Call to a member function format() on boolean




But with other dates works well:



<?php 
$date = "10.06.2015 09:25:52";
echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s');
?>


Wrong format?







php datetime date-formatting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 9 '18 at 18:59









Mohammed Zayan

4057 silver badges15 bronze badges




4057 silver badges15 bronze badges










asked Jun 10 '15 at 0:04









user1539207user1539207

831 gold badge1 silver badge7 bronze badges




831 gold badge1 silver badge7 bronze badges















  • Neither one actually work

    – John Conde
    Jun 10 '15 at 0:07











  • $date = "10.06.2015 09:25:52"; echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s'); -works

    – user1539207
    Jun 10 '15 at 0:08












  • $date = "13-06-2015 23:45:52"; echo Datetime::createFromFormat('d-m-Y h:i:s',$date )->format('Y-m-d h:i:s'); - no working anyway

    – user1539207
    Jun 10 '15 at 0:09


















  • Neither one actually work

    – John Conde
    Jun 10 '15 at 0:07











  • $date = "10.06.2015 09:25:52"; echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s'); -works

    – user1539207
    Jun 10 '15 at 0:08












  • $date = "13-06-2015 23:45:52"; echo Datetime::createFromFormat('d-m-Y h:i:s',$date )->format('Y-m-d h:i:s'); - no working anyway

    – user1539207
    Jun 10 '15 at 0:09

















Neither one actually work

– John Conde
Jun 10 '15 at 0:07





Neither one actually work

– John Conde
Jun 10 '15 at 0:07













$date = "10.06.2015 09:25:52"; echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s'); -works

– user1539207
Jun 10 '15 at 0:08






$date = "10.06.2015 09:25:52"; echo Datetime::createFromFormat('d-m-Y h:i:s', $date)->format('Y-m-d h:i:s'); -works

– user1539207
Jun 10 '15 at 0:08














$date = "13-06-2015 23:45:52"; echo Datetime::createFromFormat('d-m-Y h:i:s',$date )->format('Y-m-d h:i:s'); - no working anyway

– user1539207
Jun 10 '15 at 0:09






$date = "13-06-2015 23:45:52"; echo Datetime::createFromFormat('d-m-Y h:i:s',$date )->format('Y-m-d h:i:s'); - no working anyway

– user1539207
Jun 10 '15 at 0:09













3 Answers
3






active

oldest

votes


















23
















Neither example work as you have multiple errors:



  1. You forgot your second parameter to Datetime::createFromFormat()


  2. h:i:s should be H:i:s

  3. Your date in the second example is separated by a . not a -

Fixes:



<?php 
$date = "13-06-2015 23:45:52";
echo DateTime::createFromFormat('d-m-Y H:i:s', $date)->format('Y-m-d h:i:s');

$date = "10.06.2015 09:25:52";
echo DateTime::createFromFormat('d.m.Y H:i:s', $date)->format('Y-m-d h:i:s');
?>





share|improve this answer






















  • 1





    2. h:i:s should be H:i:s - that fixed my problem, h - 12-hour format. Thanks

    – user1539207
    Jun 10 '15 at 0:18











  • Also, this is DateTime and not Datetime

    – TwystO
    Jun 6 '16 at 9:28


















5
















In my case I was getting this error because I was using microtime(true) as input:



$now = DateTime::createFromFormat('U.u', microtime(true));


In the specific moments where microtime returns a float with only zeros as decimals, this error appeared.



So I had to verify if its decimals and add a decimal part:



$aux = microtime(true);
$decimais = $aux - floor($aux);
if($decimais<=10e-5) $aux += 0.1;
$now = DateTime::createFromFormat('U.u', $aux);


EDIT:



Due to floating point precision sometimes floor brings an incorret floor, so I had to use a more straight forward approach:



$aux = microtime(true);
$now = DateTime::createFromFormat('U.u', $aux);
if (is_bool($now)) $now = DateTime::createFromFormat('U.u', $aux += 0.001);





share|improve this answer






















  • 1





    or you could check if it is not a decimal and use 'U'

    – malhal
    Oct 27 '16 at 0:07


















0
















In my case, I sent an empty value from the input field and get's error



solution:



if ($this->input->post('date_fo_return') != "") 
$date_fo_return = $this->input->post('date_fo_return');
$date_fo_return2 = DateTime::createFromFormat('d/m/Y', $date_fo_return);
$data['date_fo_return'] = $date_fo_return2->format("Y-m-d H:i:s");






share|improve this answer



























    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%2f30744943%2fphp-fatal-error-call-to-a-member-function-format-on-boolean%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    23
















    Neither example work as you have multiple errors:



    1. You forgot your second parameter to Datetime::createFromFormat()


    2. h:i:s should be H:i:s

    3. Your date in the second example is separated by a . not a -

    Fixes:



    <?php 
    $date = "13-06-2015 23:45:52";
    echo DateTime::createFromFormat('d-m-Y H:i:s', $date)->format('Y-m-d h:i:s');

    $date = "10.06.2015 09:25:52";
    echo DateTime::createFromFormat('d.m.Y H:i:s', $date)->format('Y-m-d h:i:s');
    ?>





    share|improve this answer






















    • 1





      2. h:i:s should be H:i:s - that fixed my problem, h - 12-hour format. Thanks

      – user1539207
      Jun 10 '15 at 0:18











    • Also, this is DateTime and not Datetime

      – TwystO
      Jun 6 '16 at 9:28















    23
















    Neither example work as you have multiple errors:



    1. You forgot your second parameter to Datetime::createFromFormat()


    2. h:i:s should be H:i:s

    3. Your date in the second example is separated by a . not a -

    Fixes:



    <?php 
    $date = "13-06-2015 23:45:52";
    echo DateTime::createFromFormat('d-m-Y H:i:s', $date)->format('Y-m-d h:i:s');

    $date = "10.06.2015 09:25:52";
    echo DateTime::createFromFormat('d.m.Y H:i:s', $date)->format('Y-m-d h:i:s');
    ?>





    share|improve this answer






















    • 1





      2. h:i:s should be H:i:s - that fixed my problem, h - 12-hour format. Thanks

      – user1539207
      Jun 10 '15 at 0:18











    • Also, this is DateTime and not Datetime

      – TwystO
      Jun 6 '16 at 9:28













    23














    23










    23









    Neither example work as you have multiple errors:



    1. You forgot your second parameter to Datetime::createFromFormat()


    2. h:i:s should be H:i:s

    3. Your date in the second example is separated by a . not a -

    Fixes:



    <?php 
    $date = "13-06-2015 23:45:52";
    echo DateTime::createFromFormat('d-m-Y H:i:s', $date)->format('Y-m-d h:i:s');

    $date = "10.06.2015 09:25:52";
    echo DateTime::createFromFormat('d.m.Y H:i:s', $date)->format('Y-m-d h:i:s');
    ?>





    share|improve this answer















    Neither example work as you have multiple errors:



    1. You forgot your second parameter to Datetime::createFromFormat()


    2. h:i:s should be H:i:s

    3. Your date in the second example is separated by a . not a -

    Fixes:



    <?php 
    $date = "13-06-2015 23:45:52";
    echo DateTime::createFromFormat('d-m-Y H:i:s', $date)->format('Y-m-d h:i:s');

    $date = "10.06.2015 09:25:52";
    echo DateTime::createFromFormat('d.m.Y H:i:s', $date)->format('Y-m-d h:i:s');
    ?>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 9 '18 at 18:13

























    answered Jun 10 '15 at 0:09









    John CondeJohn Conde

    191k84 gold badges383 silver badges436 bronze badges




    191k84 gold badges383 silver badges436 bronze badges










    • 1





      2. h:i:s should be H:i:s - that fixed my problem, h - 12-hour format. Thanks

      – user1539207
      Jun 10 '15 at 0:18











    • Also, this is DateTime and not Datetime

      – TwystO
      Jun 6 '16 at 9:28












    • 1





      2. h:i:s should be H:i:s - that fixed my problem, h - 12-hour format. Thanks

      – user1539207
      Jun 10 '15 at 0:18











    • Also, this is DateTime and not Datetime

      – TwystO
      Jun 6 '16 at 9:28







    1




    1





    2. h:i:s should be H:i:s - that fixed my problem, h - 12-hour format. Thanks

    – user1539207
    Jun 10 '15 at 0:18





    2. h:i:s should be H:i:s - that fixed my problem, h - 12-hour format. Thanks

    – user1539207
    Jun 10 '15 at 0:18













    Also, this is DateTime and not Datetime

    – TwystO
    Jun 6 '16 at 9:28





    Also, this is DateTime and not Datetime

    – TwystO
    Jun 6 '16 at 9:28













    5
















    In my case I was getting this error because I was using microtime(true) as input:



    $now = DateTime::createFromFormat('U.u', microtime(true));


    In the specific moments where microtime returns a float with only zeros as decimals, this error appeared.



    So I had to verify if its decimals and add a decimal part:



    $aux = microtime(true);
    $decimais = $aux - floor($aux);
    if($decimais<=10e-5) $aux += 0.1;
    $now = DateTime::createFromFormat('U.u', $aux);


    EDIT:



    Due to floating point precision sometimes floor brings an incorret floor, so I had to use a more straight forward approach:



    $aux = microtime(true);
    $now = DateTime::createFromFormat('U.u', $aux);
    if (is_bool($now)) $now = DateTime::createFromFormat('U.u', $aux += 0.001);





    share|improve this answer






















    • 1





      or you could check if it is not a decimal and use 'U'

      – malhal
      Oct 27 '16 at 0:07















    5
















    In my case I was getting this error because I was using microtime(true) as input:



    $now = DateTime::createFromFormat('U.u', microtime(true));


    In the specific moments where microtime returns a float with only zeros as decimals, this error appeared.



    So I had to verify if its decimals and add a decimal part:



    $aux = microtime(true);
    $decimais = $aux - floor($aux);
    if($decimais<=10e-5) $aux += 0.1;
    $now = DateTime::createFromFormat('U.u', $aux);


    EDIT:



    Due to floating point precision sometimes floor brings an incorret floor, so I had to use a more straight forward approach:



    $aux = microtime(true);
    $now = DateTime::createFromFormat('U.u', $aux);
    if (is_bool($now)) $now = DateTime::createFromFormat('U.u', $aux += 0.001);





    share|improve this answer






















    • 1





      or you could check if it is not a decimal and use 'U'

      – malhal
      Oct 27 '16 at 0:07













    5














    5










    5









    In my case I was getting this error because I was using microtime(true) as input:



    $now = DateTime::createFromFormat('U.u', microtime(true));


    In the specific moments where microtime returns a float with only zeros as decimals, this error appeared.



    So I had to verify if its decimals and add a decimal part:



    $aux = microtime(true);
    $decimais = $aux - floor($aux);
    if($decimais<=10e-5) $aux += 0.1;
    $now = DateTime::createFromFormat('U.u', $aux);


    EDIT:



    Due to floating point precision sometimes floor brings an incorret floor, so I had to use a more straight forward approach:



    $aux = microtime(true);
    $now = DateTime::createFromFormat('U.u', $aux);
    if (is_bool($now)) $now = DateTime::createFromFormat('U.u', $aux += 0.001);





    share|improve this answer















    In my case I was getting this error because I was using microtime(true) as input:



    $now = DateTime::createFromFormat('U.u', microtime(true));


    In the specific moments where microtime returns a float with only zeros as decimals, this error appeared.



    So I had to verify if its decimals and add a decimal part:



    $aux = microtime(true);
    $decimais = $aux - floor($aux);
    if($decimais<=10e-5) $aux += 0.1;
    $now = DateTime::createFromFormat('U.u', $aux);


    EDIT:



    Due to floating point precision sometimes floor brings an incorret floor, so I had to use a more straight forward approach:



    $aux = microtime(true);
    $now = DateTime::createFromFormat('U.u', $aux);
    if (is_bool($now)) $now = DateTime::createFromFormat('U.u', $aux += 0.001);






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 17 '16 at 14:06

























    answered Feb 16 '16 at 14:50









    carlacarla

    1,3291 gold badge21 silver badges29 bronze badges




    1,3291 gold badge21 silver badges29 bronze badges










    • 1





      or you could check if it is not a decimal and use 'U'

      – malhal
      Oct 27 '16 at 0:07












    • 1





      or you could check if it is not a decimal and use 'U'

      – malhal
      Oct 27 '16 at 0:07







    1




    1





    or you could check if it is not a decimal and use 'U'

    – malhal
    Oct 27 '16 at 0:07





    or you could check if it is not a decimal and use 'U'

    – malhal
    Oct 27 '16 at 0:07











    0
















    In my case, I sent an empty value from the input field and get's error



    solution:



    if ($this->input->post('date_fo_return') != "") 
    $date_fo_return = $this->input->post('date_fo_return');
    $date_fo_return2 = DateTime::createFromFormat('d/m/Y', $date_fo_return);
    $data['date_fo_return'] = $date_fo_return2->format("Y-m-d H:i:s");






    share|improve this answer





























      0
















      In my case, I sent an empty value from the input field and get's error



      solution:



      if ($this->input->post('date_fo_return') != "") 
      $date_fo_return = $this->input->post('date_fo_return');
      $date_fo_return2 = DateTime::createFromFormat('d/m/Y', $date_fo_return);
      $data['date_fo_return'] = $date_fo_return2->format("Y-m-d H:i:s");






      share|improve this answer



























        0














        0










        0









        In my case, I sent an empty value from the input field and get's error



        solution:



        if ($this->input->post('date_fo_return') != "") 
        $date_fo_return = $this->input->post('date_fo_return');
        $date_fo_return2 = DateTime::createFromFormat('d/m/Y', $date_fo_return);
        $data['date_fo_return'] = $date_fo_return2->format("Y-m-d H:i:s");






        share|improve this answer













        In my case, I sent an empty value from the input field and get's error



        solution:



        if ($this->input->post('date_fo_return') != "") 
        $date_fo_return = $this->input->post('date_fo_return');
        $date_fo_return2 = DateTime::createFromFormat('d/m/Y', $date_fo_return);
        $data['date_fo_return'] = $date_fo_return2->format("Y-m-d H:i:s");







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 6:32









        teenage vampireteenage vampire

        124 bronze badges




        124 bronze badges































            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%2f30744943%2fphp-fatal-error-call-to-a-member-function-format-on-boolean%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

            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

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해