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.

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.