Jump to content

PHP and mysql time format problem


Trader77

Recommended Posts

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

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.

Archived

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

×
×
  • Create New...

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.