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
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

Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.