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;
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
add a comment |
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
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
add a comment |
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
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
php datetime date-formatting
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
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
Neither example work as you have multiple errors:
- You forgot your second parameter to
Datetime::createFromFormat() h:i:sshould beH:i:s- 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');
?>
1
2.h:i:sshould beH:i:s- that fixed my problem,h- 12-hour format. Thanks
– user1539207
Jun 10 '15 at 0:18
Also, this isDateTimeand notDatetime
– TwystO
Jun 6 '16 at 9:28
add a comment |
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);
1
or you could check if it is not a decimal and use 'U'
– malhal
Oct 27 '16 at 0:07
add a comment |
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");
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Neither example work as you have multiple errors:
- You forgot your second parameter to
Datetime::createFromFormat() h:i:sshould beH:i:s- 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');
?>
1
2.h:i:sshould beH:i:s- that fixed my problem,h- 12-hour format. Thanks
– user1539207
Jun 10 '15 at 0:18
Also, this isDateTimeand notDatetime
– TwystO
Jun 6 '16 at 9:28
add a comment |
Neither example work as you have multiple errors:
- You forgot your second parameter to
Datetime::createFromFormat() h:i:sshould beH:i:s- 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');
?>
1
2.h:i:sshould beH:i:s- that fixed my problem,h- 12-hour format. Thanks
– user1539207
Jun 10 '15 at 0:18
Also, this isDateTimeand notDatetime
– TwystO
Jun 6 '16 at 9:28
add a comment |
Neither example work as you have multiple errors:
- You forgot your second parameter to
Datetime::createFromFormat() h:i:sshould beH:i:s- 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');
?>
Neither example work as you have multiple errors:
- You forgot your second parameter to
Datetime::createFromFormat() h:i:sshould beH:i:s- 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');
?>
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:sshould beH:i:s- that fixed my problem,h- 12-hour format. Thanks
– user1539207
Jun 10 '15 at 0:18
Also, this isDateTimeand notDatetime
– TwystO
Jun 6 '16 at 9:28
add a comment |
1
2.h:i:sshould beH:i:s- that fixed my problem,h- 12-hour format. Thanks
– user1539207
Jun 10 '15 at 0:18
Also, this isDateTimeand notDatetime
– 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
add a comment |
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);
1
or you could check if it is not a decimal and use 'U'
– malhal
Oct 27 '16 at 0:07
add a comment |
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);
1
or you could check if it is not a decimal and use 'U'
– malhal
Oct 27 '16 at 0:07
add a comment |
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);
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);
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
add a comment |
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
add a comment |
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");
add a comment |
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");
add a comment |
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");
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");
answered Mar 28 at 6:32
teenage vampireteenage vampire
124 bronze badges
124 bronze badges
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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