For Example.
In the field “date_account_created” It stores a date with format “2011-12-21 03:34:21”
And that’s ok…
But when i fetch this in PHP i need to:
1) Do not print the clock “03:34:21”
2) I want to Print DD-MM-YYYY instead of YYYY-MM-DD
Is this thing possible?
You don’t change it as it’s being fetched, but rather when querying it by using
DATE_FORMAT()That is, unless you will be needing to use the date in PHP in multiple different formats. In that case, it may be simpler to select it as a UNIX timestamp, which can be natively manipulated in PHP without needing to convert via
strtotime(). This is recommended only if you intend to use the date in multiple different formats in your PHP application code. If you’re using only one format, it’s simpler to useDATE_FORMAT()in the query as above.Then manipulate in php: