Jump to content


This topic is now archived and is closed to further replies.


SELECT (wanna change date format)

Recommended Posts

Call me dumb, call me stupid. Go ahead, make my day.


I know how to do this, I just have a brain that loses cells often. As Homer once said, \"I don\'t wanna take an Adult Ed class Marge, coz everytime I learn something new, it pushes something old out of my brain. Like the time I took a wine tasting class and forgot how to drive\".


Anyway, as we all know (and love) that with mySQL, the DATE format is in YYY-MM-DD. YAY!


I have an $sql query:


$sql=\"SELECT * FROM `table` WHERE 1 AND `category` = \'wateva\' ORDER BY \'date\'\";


Now, I want that to display, DD-MM-YYYY.


Yet again, call me dumb and stupid, how do I do that?




Liam Geteu.

Share this post

Link to post
Share on other sites

This is will help u I guess


$year = substr( $tempdate, 0, 4);

$month = substr ( $tempdate, -4, 2);

$day = substr ($tempdate, -2);

$tempdate = sprintf(\"%02d-%02d-%04d\", $day, $month, $year);

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.