-1

I need help to convert JSON date into PHP date formate

I am using this API: https://www.football-data.org/documentation/api

This is the JSON value I need to convent "utcDate"
"utcDate":2018-06-23T18:00:00Z"," to php Date like Y-m-d;

Now it returns this format: 2018-08-10T19:00:00Z

I hope this makes sense :)

This is my code so far:

<?php foreach ($api->findMatchesByCompetitionAndMatchday(2021, 1)->matches as $match) { ?>


                <tr>
                    <td><?php echo $match->utcDate;?></td>  
                    <td></td>
                    <td><?php echo $match->homeTeam->name; ?></td>                        
                    <td>-</td>
                    <td><?php echo $match->awayTeam->name; ?></td>
                    <td><?php echo $match->score->fullTime->homeTeam;  ?></td>
                    <td>:</td>
                    <td><?php echo $match->score->fullTime->awayTeam;  ?></td>
                </tr>
                <?php } ?>
Armali
  • 18,255
  • 14
  • 57
  • 171

1 Answers1

0
<?php foreach ($api->findMatchesByCompetitionAndMatchday(2021, 1)->matches as $match) { ?>
            <tr>
                <td><?php echo date('Y-m-d',strtotime($match->utcDate));?></td>  
                <td></td>
                <td><?php echo $match->homeTeam->name; ?></td>                        
                <td>-</td>
                <td><?php echo $match->awayTeam->name; ?></td>
                <td><?php echo $match->score->fullTime->homeTeam;  ?></td>
                <td>:</td>
                <td><?php echo $match->score->fullTime->awayTeam;  ?></td>
            </tr>
            <?php } ?>
Derrick
  • 3,669
  • 5
  • 35
  • 50