Page 1 of 1
Error: non well formed numeric value encountered
Posted: Thu Feb 23, 2012 1:13 pm
by lakc
hey guys,
PHP code
$posteddate=$row['room_posteddate'];
$posteddate=date("d-m-Y",$posteddate); <---error points here
echo "<td>". $posteddate ."</td>";
Error msg : A non well formed numeric value encountered in....
I want to format the date from the query result within the html code, can u pls correct and perhaps refine or simplify it in one statement if its possible within the td tags???
Re: Correct me please??
Posted: Thu Feb 23, 2012 11:16 pm
by jacek
Does $posteddate contain a number ?
Re: Error: non well formed numeric value encountered
Posted: Fri Feb 24, 2012 8:01 am
by lakc
It contains a date in the format y-m-d
it contains special character hyphen, ... is this the problem?
Re: Error: non well formed numeric value encountered
Posted: Fri Feb 24, 2012 10:23 am
by bowersbros
inside the function try using strtotime() around the second parameter, see if that lets it work?
Re: Error: non well formed numeric value encountered
Posted: Sat Feb 25, 2012 9:49 pm
by jacek
If it's a MySQL date format you can use the UNIX_TIMESTAMP to turn it into something that will work with date() so in your query you would use
SELECT
`posts`.`id`,
`posts`.`title`,
UNIX_TIMESTAMP(`posts`.`time`) AS `time`
FROM `posts`
Something like that anyway
Re: Error: non well formed numeric value encountered
Posted: Sun Feb 26, 2012 6:19 am
by lakc
Jacek's and browserbros's solutions....worked...thanks again guys. thumbs up.
Re: Error: non well formed numeric value encountered
Posted: Sun Feb 26, 2012 11:03 am
by bowersbros
GO with Jacek's solution, it will be faster.
Glad we solved it though
Re: Error: non well formed numeric value encountered
Posted: Mon Feb 27, 2012 11:55 am
by jacek
bowersbros wrote:GO with Jacek's solution, it will be faster.
I think using UNIX_TIMESTAMP() in that way does the same thing as strtotime(). But MySQL runs on a separate thread and caches the result for a bit. Both of these are interesting points in an argument about performance but honestly it will make very little difference which you go with
bowersbros wrote:Glad we solved it though
Yup