Trader77 Posted March 1, 2010 Share Posted March 1, 2010 Hi I am sure this is wery easy problem for you, but I can't solve it. So here is part of my php code: $haku = mysql_query($kysely, $yhteys) or die("Virhe kyselyssä!"); echo "<table border='0' cellpadding='3' cellspacing='1' align='center'>"; echo "<tr bgcolor='#000066'><td width='20' align='center' valign='top' class='smallText'><FONT color='#FFFFFF'><b>Nro</b></td><td width='20' align='center' valign='top' class='smallText'><FONT color='#FFFFFF'><b>Etunimi</b></td><td width='20' align='center' valign='top' class='smallText'><FONT color='#FFFFFF'><b>Sukunimi</b></td><td align='center' valign='top' class='smallText'><FONT color='#FFFFFF'><b>Sähköposti</b></td><td align='center' valign='top' class='smallText'><FONT color='#FFFFFF'><b>Liittymisaika</b></td><td align='center' valign='top' class='smallText'><FONT color='#FFFFFF'><b>Syntymäaika</b></td></tr>"; //käydään jäsentiedot läpi for ($i = 0; $i < mysql_num_rows($haku); $i++) { //haetaan tiedot muuttujiin $nro = mysql_result($haku, $i, "N/O"); $etunimi = mysql_result($haku, $i, "etunimi"); $sukunimi = mysql_result($haku, $i, "sukunimi"); $oso = mysql_result($haku, $i, "osoite"); $postint = mysql_result($haku, $i, "postint"); $email = mysql_result($haku, $i, "email"); $saika = mysql_result($haku, $i, "saika"); $laika = mysql_result($haku, $i, "laika"); $ip = mysql_result($haku, $i, "ip"); //tulostetaan taulukon rivi echo "<tr bgcolor='#E7E7E7'><td>$nro</td><td>$etunimi</td><td>$sukunimi</td><td>$email</td><td>$laika</td><td>$saika</td></tr>"; } echo "</table>"; $saika is date and it's format is like 2010-01-02. How can I change the format like 02.01.2010. Link to comment https://forums.phpfreaks.com/topic/193821-php-and-mysql-time-format-problem/ Share on other sites More sharing options...
JAY6390 Posted March 1, 2010 Share Posted March 1, 2010 in your query select the date using the DATE_FORMAT function along with the date formatting options you require Optionally you can use strtotime() in php to convert the date to a unix timestamp, then format it using the date() function Link to comment https://forums.phpfreaks.com/topic/193821-php-and-mysql-time-format-problem/#findComment-1020111 Share on other sites More sharing options...
DarkSuperHero Posted March 1, 2010 Share Posted March 1, 2010 datePieces = explode("2010-01-02", "-"); dateDesired = datePieces[2] .".".datePieces[1] .".".datePieces[0] ."."; echo(dateDesired); Something of that sort should do the trick also Link to comment https://forums.phpfreaks.com/topic/193821-php-and-mysql-time-format-problem/#findComment-1020112 Share on other sites More sharing options...
Trader77 Posted March 4, 2010 Author Share Posted March 4, 2010 in your query select the date using the DATE_FORMAT function along with the date formatting options you require Optionally you can use strtotime() in php to convert the date to a unix timestamp, then format it using the date() function ' Thank you!! This helped. Link to comment https://forums.phpfreaks.com/topic/193821-php-and-mysql-time-format-problem/#findComment-1021480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.