This question already has an answer here:
PHP:
<p><img src="<?php echo base_url()?>assets/images/calendar.png" alt=""><?php echo date('d m Y', str_replace('/', '-', $pet['pet_lost_date']))?> by <?php echo $pet['reg_first_name'].' '.substr($pet['reg_last_name'], 0, 1);?>.<b></b> </p>
Error:
A non well formed numeric value encountered
It displaying Error. How can I resolve this Error please help me.
</div>
date()
takes an integer timestamp as the second argument, not a string. Try strtotime()
:
echo date('d m Y', strtotime(str_replace('/', '-', $pet['pet_lost_date'])));
But if your date string is in the proper format, don't replace:
echo date('d m Y', strtotime($pet['pet_lost_date']));
But be careful as strtotime()
treats dates with a /
as U.S. style dates m/d/Y
and dates with -
are treated as d-m-Y
, or maybe that's what you are trying to correct?