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 Quote Link to comment 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 Quote Link to comment 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 | +------------+------------+ 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.