Rommeo Posted February 23, 2008 Share Posted February 23, 2008 hi i m new at php-programming. i have a problem about getting time from mysql, as you know DATETIME function stores the data like : 2001-12-27 13:30:00 But i want to use it like 27.17.2001 Here s the code i m using <?php include 'db.php'; $sql = "SELECT * FROM tablepeople"; $results = mysql_query($sql) or die(mysql_error()); $result=mysql_query($sql); $num=mysql_numrows($result); $i=0; while ($i < $num) { $nickname=mysql_result($result,$i,"nickname"); $birthdate=mysql_result($result,$i,"birthdatetime"); echo "<b>$nickname 's birthdate is $birthdate</b>"; $i++; } As you know this code is not working cause i have just noticed that i should convert datetime into the format i m using, i have searched for it but could not find any information as much as i need. i just want to print it like : Dido's birthdate is 27.12.1974 John's birthdate is 04.06.1970..etc. i ll be glad if you can help, waiting for this part to finish for to pass next step. Thanx in advance. Link to comment https://forums.phpfreaks.com/topic/92647-getting-datetime-from-mysql-and-changing-format/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 23, 2008 Share Posted February 23, 2008 Use the mysql DATE_FORMAT() function in your SELECT query to output the date in any format you want - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format Link to comment https://forums.phpfreaks.com/topic/92647-getting-datetime-from-mysql-and-changing-format/#findComment-474814 Share on other sites More sharing options...
Rommeo Posted February 23, 2008 Author Share Posted February 23, 2008 Thanx for the reply but are you sure that the link is correct ? Cause i could not enter, also my friends could not enter. will be glad if you tell me what to do. Link to comment https://forums.phpfreaks.com/topic/92647-getting-datetime-from-mysql-and-changing-format/#findComment-474816 Share on other sites More sharing options...
jandrews3 Posted February 24, 2008 Share Posted February 24, 2008 The link worked for me. Link to comment https://forums.phpfreaks.com/topic/92647-getting-datetime-from-mysql-and-changing-format/#findComment-474824 Share on other sites More sharing options...
Rommeo Posted February 24, 2008 Author Share Posted February 24, 2008 Thanx jandrews3 so you can read it. That would be very nice if you told me what to do after reading the link.. Link to comment https://forums.phpfreaks.com/topic/92647-getting-datetime-from-mysql-and-changing-format/#findComment-474828 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.