How to convert MySQL timestamp to d-m-yyyy
$newTime = "TIME_FORMAT(date, '%e-%M-Y') AS date"; $result = mysqli_query($connect, "SELECT id, firstname, lastname, email, text, $newTime FROM gastenboek");
This is some information selecten from the database, i want to convert the sql timestamp to php days - months - years (22-11-2013).
The query works fine but date = NULL
it seems that my query is wrong, because when i do SELECT * FROM gastenboek it all works fine.
Error code: Notice: Trying to get property of non-object
I already googled the problem but i can't find the solution.
Sorry for my bad english, and thanks in advanced!
Greetings from Holland
You need to use
DATE_FORMAT instead of
TIME_FORMAT. And I think your format string needs to be tweaked. Try this:
DATE_FORMAT(date, '%e-%c-%Y') AS date
The docs for
This is used like the DATE_FORMAT() function, but the format string may contain format specifiers only for hours, minutes, seconds, and microseconds. Other specifiers produce a NULL value or 0.
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]