I’m trying to convert a date from the format (YYYY-mm-dd) to asnother format (d/m/YYYY) but it throws a warning

Notice: A non well formed numeric value encountered in C:\wamp\www\shoresrentals\admin\list_users.php on line [I]39

$d = $row['created'];
echo "<td>".date("Y/m/d",$d)."</td>";

Whats the deal? am I using date() correctly?[/I]

Cast the row to its intval

$d = intval($row['created']);
echo "<td>".date("Y/m/d")."</td>";

[fphp]date[/fphp] doesn’t support float timestamps, only integers. If you need to work with those, use the DateTime class instead.

If $row[‘created’] is in YYYY-mm-dd format, you would use

$d = strtotime($row['created']);
echo "<td>".date("Y/m/d",$d)."</td>";

since date() expects a timestamp int, not a date string.


here is one simple function to do so:

function print_this_date($var) {
  if($var == '0000-00-00' OR $var == '') {
    echo '';
  else {
    list($yy, $mm, $dd) = explode ('-', $var);
    return date('d/m/Y', mktime(0, 0, 0, $mm, $dd, $yy));


echo '<td>' . print_this_date($row['created']) . '</td>';

Investigate date() function for further examples of its possibilities.