Date Format
Posted: Thu Jan 26, 2006 4:11 pm
I have a date stored in a database in this format ("m-d-Y"). I want to print out the date in a table but only showing the month and day ex: ("m-d"). The code bellow is my attempt so far, not working obviously, the date does not print out:
Code: Select all
<table align="right" width="520" border="0" cellpadding="0" cellspacing="1">
<tr>
<td align="center" height="30" class="topBar"><b>CONTROL #</b></td>
<td align="center" height="30" class="topBar"><b>DATE ORD</b></td>
<td align="center" height="30" class="topBar"><b>CUST</b></td>
<td align="center" height="30" class="topBar"><b>INSURED</b></td>
<td align="center" height="30" class="topBar"><b>LOCATION</b></td>
<td align="center" height="30" class="topBar"><b>POLICY #</b></td>
<td align="center" height="30" class="topBar"><b>RT</b></td>
<td align="center" height="30" class="topBar"><b>ASSGN</b></td>
</tr>
<?php
$result = mysql_query("SELECT control_number,date_ordered,user_code,name_of_insured,location_city,policy_number,survey_type,DATE_FORMAT(date_assigned, '%m-%d') AS date_assigned FROM cases WHERE inspector_code='" . $_POST["inspector_code"] . "' AND sent_to_reviewer='false' ORDER BY control_number ASC");
while($row = mysql_fetch_array($result)) {
if($row["rush"] == true) {
$class = "redBar";
} else {
$class = "greenBar";
}
?>
<tr>
<td align="center" height="30" class="<?php echo $class; ?>"><b><?php echo $row["control_number"]; ?></b></td>
<td align="center" class="<?php echo $class; ?>"><?php echo $row["date_ordered"]; ?></td>
<td align="center" class="<?php echo $class; ?>"><?php echo $row["user_code"]; ?></td>
<td align="center" class="<?php echo $class; ?>"><?php echo substr($row["name_of_insured"], "0", "15"); ?></td>
<td align="center" class="<?php echo $class; ?>"><?php echo substr($row["location_city"], "0", "10"); ?></td>
<td align="center" class="<?php echo $class; ?>"><?php echo $row["policy_number"]; ?></td>
<td align="center" class="<?php echo $class; ?>"><?php echo substr($row["survey_type"], "0", "2"); ?></td>
<td align="center" class="<?php echo $class; ?>">
<?php echo $date_assigned; ?>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="8"><br> </td>
</tr>
</table>