$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
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
date_format() was throwing an error because the first parameter being supplied was not an instance of a PHP DateTime object. It has nothing to do with what the database column is set as.
If you're receiving a 1970-01-01 that means strtotime received a null value, or a value outside of the 1970 - 2038 range approximately. The php DateTime class should be used when possible, to avoid this.
If your date is stored in the database as a datetime field type, this is an easy transition.