I have a tried numerous examples on stack already and I cant seem to get this right! I am trying to pull the date from this DateTime Object also the reason for the two lines of time was because I was trying different methods and compare the return.
[created] => DateTime Object
(
[date] => 2019-06-06 15:22:25.720000
[timezone_type] => 1
[timezone] => +00:00
)
but for some reason i'm getting the completely wrong date and time.
19-09-04 22:37:18
1970-01-01 01:00:00
19-09-04 22:37:18
1970-01-01 01:00:00
19-09-04 22:37:18
1970-01-01 01:00:00
19-09-04 22:37:18
1970-01-01 01:00:00
I've tried the following: JSON Array to PHP DateTime PHP date time from string Arrays - foreach brings ->Fatal error: Cannot use object of type
PHP CODE:
<?php
$vPaccomments = $issue->fields->comment->comments;
foreach ($vPaccomments as $vPaccomment) {
$vPacAvatarUrl = $vPaccomment->author->avatarUrls;
$size16 = "16x16";
$vPacCreated = $vPaccomment->created;
$vPacDate = $vPacCreated->date;
$vPacDateConv = date('Y-m-d H:i:s',strtotime($vPacDate));
$dateTime = new DateTime($vPacDate);
echo $dateTime->format('y-m-d H:i:s');
echo '<pre>'; print_r($vPacDateConv);
echo "<div class=\"col\">";
//echo "<img width=\"16px\" src=\"" . $vPacAvatarUrl[$size16] . "\"> " . "<font color=\"#0015ff\">" .$vPaccomment->author->displayName ."</font> added a comment - " . date_format($vPacCreateDate, 'Y-m-d H:i:s');
echo "<br>";
echo "<hr>";
echo "</div>";
}
?>
If I echo '<pre>'; print_r($vPacCreated);
I get the correct results i want to grab
DateTime Object
(
[date] => 2019-06-06 15:22:25.720000
[timezone_type] => 1
[timezone] => +00:00
)
DateTime Object
(
[date] => 2019-06-07 13:58:31.970000
[timezone_type] => 1
[timezone] => +00:00
)
DateTime Object
(
[date] => 2019-06-17 14:07:23.040000
[timezone_type] => 1
[timezone] => +00:00
)
DateTime Object
(
[date] => 2019-06-17 14:25:13.840000
[timezone_type] => 1
[timezone] => +00:00
)
Here is the portion of the values:
[comment] => JiraRestApi\Issue\Comments Object
(
[startAt] => 0
[maxResults] => 4
[total] => 4
[comments] => Array
(
[0] => JiraRestApi\Issue\Comment Object
(
[self] => https://xxx/rest/api/2/xxx
[id] => xxx
[author] => JiraRestApi\Issue\Reporter Object
(
[self] => https://xxx/rest/api/2/xxx
[name] => xxx
[emailAddress] => xxx
[avatarUrls] => Array
(
[48x48] => https://xxx/secure/useravatar?avatarId=xxx
[24x24] => https://xxx/secure/useravatar?size=small&avatarId=xxx
[16x16] => https://xxx/secure/useravatar?size=xsmall&avatarId=xxx
[32x32] => https://xxx/secure/useravatar?size=medium&avatarId=xxx
)
[displayName] => xxx
[active] => 1
[wantUnassigned:JiraRestApi\Issue\Reporter:private] =>
[accountId] =>
[key] => xxx
[timeZone] => America/New_York
)
[body] => xxx
CREATED ON:6/6/2019
COPIED TO:\\xxx
[updateAuthor] => JiraRestApi\Issue\Reporter Object
(
[self] => https://xxx/rest/api/2/xxx
[name] => xxx
[emailAddress] => xxx
[avatarUrls] => Array
(
[48x48] => https://xxx/secure/useravatar?avatarId=xxx
[24x24] => https://xxx/secure/useravatar?size=small&avatarId=xxx
[16x16] => https://xxx/secure/useravatar?size=xsmall&avatarId=xxx
[32x32] => https://xxx/secure/useravatar?size=medium&avatarId=xxx
)
[displayName] => xxx
[active] => 1
[wantUnassigned:JiraRestApi\Issue\Reporter:private] =>
[accountId] =>
[key] => xxx
[timeZone] => America/New_York
)
[created] => DateTime Object
(
[date] => 2019-06-06 15:22:25.720000
[timezone_type] => 1
[timezone] => +00:00
)