how to change the date order?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

how to change the date order?

Post by itsmani1 »

Code: Select all

<?PHP

while ($rowReport = mysql_fetch_object($resReport)) &#123;
	$Rdate =stripslashes($rowReport->appid);
	echo $Rdate;	
?>
$Rdate is returning me date and time like this:
2004-12-21 05:01 -> Year-Month-Day and time
but what i want is: like this
21-12-2004 05:01 -> Day-Month-year
means i want change in order

can any one solve this prob.
bytte
Forum Commoner
Posts: 75
Joined: Sun Nov 23, 2003 8:20 am
Location: Belgium

Post by bytte »

You can use a series of substr() to generate your way of writing down a date.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

as you are using mysql, use the date_format function mysql has...

i believe it's something like (the mysql manual knows better than me, so look it up there to be sure)

Code: Select all

SELECT DATE_FORMAT(somedatecolumn, '%d-%m-%Y %h:%i:%S') AS somedatecolumn
Post Reply