I'm currently working on a page, where I've got a problem with getting the date from the database table.
It looks like, i have now an own kinda array for the datetime column.
print_r of my database:
$projwebt = $viewmanager->getViewPageProjwebtProjekte();
echo "<pre>";
print_r($projwebt);
echo "</pre>";
Output:
Array
(
[0] => viewPageProjwebtProjekte Object
(
[id] => 1
[projectnumber] => 1
[name] => Title
[progress] => 37
[status] => 1
[responsible] => user
[customer] => user
[definition] => 1
[effort] => 15
[priority] => 12
[startdate] => DateTime Object
(
[date] => 2016-11-25 00:00:00.000000
[timezone_type] => 3
[timezone] => Europe/Belgrade
)
[targetdate] => DateTime Object
(
[date] => 2017-08-31 00:00:00.000000
[timezone_type] => 3
[timezone] => Europe/Belgrade
)
works fine:
<?php
foreach ( $projwebt as $projobject )
{
?>
<tr class="<?=$projobject->status?>">
<th colspan="2"><h2><a href="#"><?=$projobject->name?></a></h2></th>
<th colspan="2"><h2><?=$projobject->definition?></h2></th>
<th colspan="2"><h2><?=$projobject->progress?>%</h2></th>
</tr>
<?php
}
?>
here it breaks, because of the startdate:
<tr>
<td class="responsible">Zuständig:</td>
<td class="responsibleName"><?=$projobject->responsible?></td>
<td class="effort">Aufwand:</td>
<td><?=$projobject->effort?> MT</td>
<td class="start">Start:</td>
<td class="startDate"><?=$projobject->startdate?></td>
</tr>
datamapper:
$pageProjwebtProjekte->startdate = $row['startdate'];
$pageProjwebtProjekte->targetdate = $row['targetdate'];
viewmanager:
$viewPageProjwebtProjekte->startdate = $value->startdate;
$viewPageProjwebtProjekte->targetdate = $value->targetdate;
when I pick the date to display (object oriented) it breaks.
So is there a way to pick the date element of the array startdate/ targetdate? what do i have to set in my classes (viewmanager/ mapper...)?
I have no problem, when I try to display definition or effort and so on.
Thank you for having a look!
<?=is shorthand for<?php echoand perfectly validDateTimeobject. That does not happen automatically, you are doing that yourself and you can format its value using theformat()method.