Jump to content

Getting DATETIME from mySql and changing format


Rommeo

Recommended Posts

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.

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.