I have an array $creation_date[] that I am looping through. This contains MySQL timestamps. I want to change these timestamps into dates like January 4, 1992. I have this code: date('F j, Y', $creation_date[$i]) (its in a while loop with $i incrementing it). It is returning an error at that line A non well formed numeric value encountered. Any idea what is wrong?
I have an array $creation_date[] that I am looping through. This contains MySQL timestamps.
Share
You first have to use the strtotime() function.
date() assumes a unix timestamp (like time()) as a second argument, and the string coming from mysql is a string 🙂
Try date(‘F j, Y’, strtotime($creation_date[$i]));