I'm trying to get data out of JIRA and into a table. I have got the API request working and I have got almost all the data out of JIRA and into the table that I need, I just can't seem to get the created date out as it is in a datetime object within the array and doesn't have a proper format.
foreach ($ret->issues as $issue)
{
$date = new DateTime($issue->fields->created->date);
$date = $date->format('Y-m-d');
echo '<tr>
<td>'.$issue->fields->status->name.'</td>
<td>'.$date.'</td>
<td>'.$issue->fields->priority->name.'</td>
<td>'.$issue->fields->summary.'</td>
<td>'.$issue->fields->assignee->displayName.'</td>
</tr>';
}
That is the PHP code for building the table, as you can see I've tried to format it with DateTime.
Here is the array if I die on $issue->fields->created
object(DateTime)#318 (3) {
["date"]=>
string(26) "2018-10-22 12:47:02.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "-04:00"
}
I just can't seem to get that data out as $issue->fields->created->date shows me:
PHP Fatal error: Cannot use object of type DateTime as array
Which is why I tried to format it as above. Now I get:
PHP Notice: Undefined property: DateTime::$date
Any ideas?