I have a mySQL database with a timestamp field. It currently only has one entry while I’m testing, it is
2010-02-20 13:14:09
I am pulling from the database and using
echo date("m-d-Y",$r['newsDate'])
My end result is showing as
12-31-69
Anyone know why?
Edit:
editedit:
disregard that edit… the FTP addon for notepad++ timed out and unfortunately doesn’t display an error when it can’t synch.
The
datefunction expects an UNIX timestamp as its second parameter — which means you have to convert the date you get from the DB to an UNIX timestamp, which can be done usingstrtotime:And you’ll get :
You were passing the
'2010-02-20 13:14:09'string to thedatefunction ; that string is not a valid UNIX Timestamp.'12-31-69‘ is probably1970-01-01, in your locale ; and1970-01-01is the Epoch — the date that corresponds to the 0 UNIX Timestamp.