• You are not logged in. | Login

Post a reply

November 16, 2006 8:09 pm

date format problem

I've got a script that reads a date in MySQL's 'datetime' format from my database.  I need to know how to reformat this date into a M-D-YY format, stripping off the time and adding 1 year to the date in the table.

Here's the code I've got so far:

<?php

$query = "SELECT id, date FROM utable WHERE id='$_GET[id]'";
$res = mysql_query($query);

while ($row = mysql_fetch_array($res, MYSQL_BOTH)) {
   echo "ID: " . $row[id] ."<br>";
   echo "DATE: ". $row[date] . "<br>";
}

I tried using the PHP date() function on $row[date] but that just gives me an error - i think that it needs t be a unix timestamp to use that, but I've got a formated DATETIME in the database.  Any ideas?


 

 
  • Actions
  • Top
ITCrimea. Ukraine Web Development Company. Professional Developers and Web Designers Team
Custom Web Designs, Internet Applications, E-Commerce Websites, Interactive Sites, Database-Driven Sites and Services