Pedro Graca wrote:
JDJones wrote:
What if I decide to store it like that using the defaulted "2000-09-15"
format. How can I pull the numbers out to get it to print the result as
"09-2000" ?
Do it either on the SQL side:
( see http://www.mysql.com/doc/en/Date_and...functions.html )
mysql> select date_format(now(), '%m-%Y');
+-----------------------------+
| date_format(now(), '%m-%Y') |
+-----------------------------+
| 03-2004 |
+-----------------------------+
1 row in set (0.00 sec)
or on the PHP side:
( see http://www.php.net/date )
echo date('m-Y', $db_date);
I can't get either one to work. :(
I have the dates entered in a db date column called "submitted". It is
in the 0000-00-00 format. I am executing the query like: $query =
"select * from table where category = 'text' order by submitted DESC";
Then, cutting out extraneous portions of the script I am printing it by
doing this:
<?php
while ($row= mysql_fetch_array($result)) {
$title1 = $row["text"];
$title2 = $row["submitted"];
?>
<table border="2" width="100%" cellspacing="2" callpadding="0"
class="tableblue">
<tr>
<td width="100%"><? echo "<br><span
class=\"number\">$count.)</span> $title1 $title2<br><br>"?></td>
</tr>
</table>
I can't get either of your two suggested methods to work. The echo
date('m-Y', $db_date); one output the correct format I was seeking when
I modified it - echo date('m-Y', $title2); - but everything was coming
up 12-1969 no matter what the dates were that were actually in the
field. What am I still doing wrong?