date() method, A non well formed numeric value encountered does not want to format a date passed in $_POST
From the documentation for strtotime()
:
Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.
In your date string, you have 12-16-2013
. 16
isn't a valid month, and hence strtotime()
returns false
.
Since you can't use DateTime class, you could manually replace the -
with /
using str_replace()
to convert the date string into a format that strtotime()
understands:
$date = '2-16-2013';
echo date('Y-m-d', strtotime(str_replace('-','/', $date))); // => 2013-02-16
A non well formed numeric value encountered
Because you are passing a string as the second argument to the date function, which should be an integer.
string date ( string $format [, int $timestamp = time() ] )
Try strtotime which will Parse about any English textual datetime description into a Unix timestamp (integer):
date("d", strtotime($_GET['start_date']));
A non well formed numeric value encountered show When to get current date and current time
simply use time()
function
<?php
echo time();
?>
A non well formed numeric value encountered in php
There is a typo.
echo '<h1>' . fread($myfile,filesize("names.txt")) . '</h1>';
The fread included h1
after the filesize function.
A non well formed numeric value encountered on Date()
The second argument to date
is expected to be a UNIX timestamp integer. "2016-02-05 12:03:00"
is a string, not an int
, and most certainly not a UNIX timestamp.
To turn a human readable date format into a UNIX timestamp, run it through strtotime
. To turn a UNIX timestamp into a human readable date, format it with date
.
I want to set the value of input datetype but it is not set
Alright here is what I've gathered,
Left side is chrome and in right side is Mozilla
In both the cases you simply needs to pass the value to the input by default,so i think you can achieve your desired output just by placing value like this XX:XX | 02:30.
<input id="estimated_work_time" type="time" name="estimated_work_time" value="{{ date('h:i',strtotime($param->estimated_work_time)) }}">
Here is the test i make it to understand it better
<?php
// If i run this
echo date('h:i','2:30');
// I will get this error PHP Notice: A non well formed numeric value encountered
// So first you need to convert your date or time string into the proper format
echo date('h:i',strtotime('2:30'));
// this will return output this : 02:30
?>
Bizarre behaviour of some of my code using strftime()
According to the manual : http://php.net/manual/en/function.strftime.php
If you're passing something other than a timestamp you're doing it wrong. Can't really say why the first one passes and the second one doesn't. Maybe PHP is trying to compensate. In any case, if you have a text time representation, you need to call strtotime()
on it first.
EDIT
I ran the following code in my system
$row['date'] = '2011-04-06 08:33:29';
echo strftime("%a %H:%M", $row['date']);
echo '<br>';
echo strftime("%A %H:%M", $row['date']);
And I got this as the output
Notice: A non well formed numeric value encountered in F:\webroot\utils\test.php on line 4
Thu 00:33
Notice: A non well formed numeric value encountered in F:\webroot\utils\test.php on line 6
Thursday 00:33
You should have notices enabled on your system. Changing it to timestamp should solve it.
EDIT 2
...Also, I can just remove the DB code,
and generate the date with mktime or
with strtotime and it still doesn't
work
If you could post the sample that doesn't work we could have a look
php date time showing 1970 after adding hours to it
The second argument for strtotime()
needs to be a valid timestamp, you in your example:
strtotime('+5 hours', $datetime)
should be:
strtotime('+5 hours', strtotime($datetime))
Related Topics
PHP $_Get and $_Post Undefined Problem
Php: Variable-Length Argument List by Reference
Using PHP Include to Separate Site Content
PHP Loop; How to Print Each Result and Delay It for a Second Before Echoing Another Result
Getimagesize() Not Returning False When It Should
PHP Readfile() Adding Extra Bytes to Downloaded File
Best Method for Converting a PHP Array to JavaScript
Convert an Array of Strings, Each String Has Dot Separated Values, to a Multidimensional Array
Switching to Prepared Statements
Asynchronous Http Requests in PHP
Read the Longest String from an Array in PHP 5.3
Download Multiple Files as a Zip Folder Using PHP
Change Cart Item Prices Based on Custom Cart Item Data in Woocommerce