This question already has an answer here:
I have one doubt. I have in mySQL database a date with the format "NOW()": 2013-01-28 12:53:26 where I create a ticket. So, I want to get this data and convert to this: date("YmdHis"), using a query.
I've tried to do something like this, using a variable on echo:
$get_data = $rsres->Fields('create_time');
echo gmdate("YmdHis",$get_data);
However without sucess. What's the problem?
Thanks.
</div>
Use date()
and strtotime()
echo date("YmdHis", strtotime($get_data));
gmdate() expects a UNIX timestamp. Your sql data is not in that format. You first have to convert it to such using for example strtotime
Why don't you modify your query? Check this:
SELECT FORMAT(column_name,format) FROM table_name;
Let me know if useful.
You can use this to convert your Date
echo date("YmdHis", strtotime($myDate));