Tricky code issue to display a date from the database

I have a form that allows a person to upload contract details, and a apart of that is to upload a date range using the line of code below:


<script type="text/javascript">DateInput('contractEnd', true<?php if(isset($cEnd)){if (!empty($cEnd)){echo ",'YYYY-MM-DD', '$cEnd'";}}?>)</script>

Works perfectly this.

But my problem is when I try to display that date to the user and it has to fit in like the code below:


echo "<td width='60' class='tableData'>".$data["Contract_Length"]."</td>";

The name of the field is Contract_Start so need to use that rather than $cEnd or similar, as above…

Have tried and all I get is white out. I dont need any of the if statements in there, just be able to display the date in the correct format.

Then maybe changing $data[“Contract_Length”] in $data[‘Contract_Start’] would help?

Hi guido2004,

I though that and tried it and came back with this error.

Catchable fatal error: Object of class DateTime could not be converted to string in

http://www.php.net/manual/en/datetime.format.php

Thank you, got it working like this:


echo "<td width='80' class='tableData'>".date_format($data['Contract_Start'], 'd/m/y')."</td>";