I have an array $creation_date[] that I am looping throu开发者_JAVA技巧gh. 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?
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]));
not sure on that error but i think you need strtotime in there: date('F j, Y', strtotime($creation_date[$i]))
if that doesn't work, as you looping if you print the $creation_date[$i] does it print as expected?
精彩评论