Mr_Irnonic Posted November 16, 2014 Share Posted November 16, 2014 Hello dear members, first of all sorry for my grammer i'm from Switzerland . So now: I have a problem with php. I want to put out the date of a blogpost in this format dd:mm:yyyy instead of yyyy:mm:dd. I tried it a long time and used many different ways like: date, dateformat, strto etc. but at the and nothing worked for me. So here is a picture of the blogpost and i'll add the file with my compressd php code. I'd be glad if you could help me Regards Mr_Ironic help.php Link to comment https://forums.phpfreaks.com/topic/292493-phpmysql-date-output/ Share on other sites More sharing options...
Mr_Irnonic Posted November 16, 2014 Author Share Posted November 16, 2014 I found the solution please delete this therad Link to comment https://forums.phpfreaks.com/topic/292493-phpmysql-date-output/#findComment-1496703 Share on other sites More sharing options...
Barand Posted November 16, 2014 Share Posted November 16, 2014 For the benefit of those looking for a solution, there are two ways 1. Using PHP date() function to format the date output $sql = "SELECT thedate FROM dates"; $res = $db->query($sql); list($thedate) = $res->fetch_row(); echo "| $thedate | " . date('d:m:Y', strtotime($thedate)) . " |<br>"; /* OUTPUT | 2014-11-16 | 16:11:2014 | */ 2. Using MySQL DATE_FORMAT() function mysql> SELECT -> thedate -> , DATE_FORMAT(thedate, '%d:%m:%Y') as formatted -> FROM dates; +------------+------------+ | thedate | formatted | +------------+------------+ | 2014-11-16 | 16:11:2014 | +------------+------------+ Link to comment https://forums.phpfreaks.com/topic/292493-phpmysql-date-output/#findComment-1496715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.