Apparently your add_date column is not a datetime column in the database. Read more in the manual .
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
If your column is a varchar, then you can use the date_create before the date_format, as in the first example in the manual.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
I think this could help you.
$row_rs_propdetails['add_date']=strtotime($row_rs_propdetails['add_date']);//this will convert mysql text date to php date object
echo date('Y-m-d',$row_rs_propdetails['add_date'] );//now show date object in required format
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
If your column is a date type then this should work:
echo date('Y-m-d', $row_rs_propdetails['add_date']);
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
This worked - as in it removed the time and just left the date - however it switched all the dates to 1970-01-01
Not sure why as it should just be formatting.....
It will not work because php date and mysql date do not recongize each other.
So when you load php variable with mysql datevalue, its just string for it not date.
So we first convert that string to php date object using strtotime function.
then we use that php date object using various php display formats
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270