0

How can I resolve this problem? Why it displaying error such as A non well formed numeric value encountered.

PHP:

date("m-d-Y",str_replace('/', '-', 05/18/2017));
shah rushabh
  • 31
  • 1
  • 6
  • Date format isn't working on your variable. Try assigning all that str_replace, to a variable and echoing it out and seeing how it is being displayed – clearshot66 May 17 '17 at 15:09
  • Try using the `DateTime` class instead: http://php.net/manual/en/datetime.createfromformat.php – aynber May 17 '17 at 15:09
  • 1
    `05/18/2017` is not a string unless it's `"05/18/2017"` or `'05/18/2017'` – Don't Panic May 17 '17 at 15:09
  • The second parameter of `date` should not be a string. Did you forget to use `strtotime` there? – Don't Panic May 17 '17 at 15:11
  • Also, with the format you're using, converting your date string to a timestamp and then formatting it with `date` is redundant. It will already be in "m-d-Y" format after you do the `str_replace`. – Don't Panic May 17 '17 at 15:14

0 Answers0