Jump to content


SELECT (wanna change date format)

  • Please log in to reply
2 replies to this topic

#1 LiamG

  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts
  • LocationMelbourne, Australia

Posted 13 February 2003 - 08:42 AM

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.

#2 shivabharat

  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 13 February 2003 - 05:17 PM

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);
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 effigy

  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 13 February 2003 - 05:49 PM

have a look down the page at DATE_FORMAT
if you use this you will have to name your columns instead of using *

if you prefer to do it afterwards in php - use the date() function in php - check www.php.net
Regexp | Unicode Article | Letter Database

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users