Jump to content

A non well formed numeric value encountered


Go to solution Solved by Psycho,

Recommended Posts

I am trying to echo a date using the following code

 

 

<?php echo date(strtotime("d M Y",$order_row['od_date']));?>

 

but I am getting the following error message

 

Notice: A non well formed numeric value encountered in /Applications/MAMP/htdocs/Nick Morris/admin/invoice.php on line 86

 

The data type for the field from the database is DateTime, any ideas what is going wrong

  • Solution

You need to look at those two functions and what they expect - you have the parameters messed up.

 

date() takes a string as the first parameter to determine the format and an optional second parameter for a timestamp

 

strtotime() takes a string representing a data and an optional second parameter of a timestamp.

 

Your code has both of the parameters for those two function put into the strtotime() function. So,it is giving you that error because the second parameter you passed to strtotime() is not a timestamp.

 

Try

 

<?php echo date("d M Y", strtotime($order_row['od_date']));?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.