PHP日期和时间格式

I have the following table, I got all info correctly but the "date" appears in one block format:

<?php
   // search for desired team
   $searchQuery = $api->searchTeam(urlencode("Real Madrid"));
   // var_dump searchQuery and inspect for results
   $response = $api->getTeamById($searchQuery->teams[0]->id);
   $fixtures = $response->getFixtures('home')->fixtures;
?>

<tr>
    <td><?php echo $fixture->homeTeamName; ?></td>
    <td>-</td>
    <td><?php echo $fixture->awayTeamName; ?></td>
    <td><?php echo $fixture->result->goalsHomeTeam; ?></td>
    <td>:</td>
    <td><?php echo $fixture->result->goalsAwayTeam; ?></td>
    <td><?php echo $fixture->date; ?></td>
</tr>

Result:

Home Team           Away Team           Result        Date/Time
Real Madrid CF  -   RC Celta de Vigo    2   :   1     2016-08-27T18:15:00Z

how to add space between the date and time and remove the T and Z characters while I dont have access to php.ini file?

Look at the date() function, which offers many customization possibilities.

For the current case you might choose to write, for instance:

<td><?php echo date('m/d/Y h:i A', $fixture->date); ?></td>

You should use the date function with the strtotime. This will allow you to format your string as you want it. For example:

echo date('Y-m-d h:i:s', strtotime('2016-08-27T18:15:00Z'));

Note the h here is a 12 hour format. For 24 hour format use G.

Demo: https://eval.in/653840

See http://php.net/manual/en/function.date.php for the different date characters.

Alternatively you could use str_replace but that would just replace ts and zs.

echo str_replace(array('T', 'Z'), array(' ', ''), '2016-08-27T18:15:00Z');

Demo: https://eval.in/653838

Depending on the answers of @cFreed, @chris85 and other contributors, I got it working this way:

echo str_replace(array('T', 'Z'), array(' ', ''), $fixture->date);

result: 2016-08-27 18:15:00

Your date is not a timestamp so you can use string manipulation to remove T and z by creating simply a function which you can use in future..

function replace_str($originastring,$valuetoreplace,$valueasreplacement)
{
  if(isset($originalstring)&&isset($valuetoreplace)&&isset($valueasreplacement))
   {
      if(is_array($valuetoreplace)&&is_array($valueasreplacement)&&($valutoreplace.length==$valueasreplacement.length))
       {
           for($i=0;$i<$valuetoreplace.length;$i++) 
             {
              $originalstring=str_replace($originalstring,$valueasreplacement[i]);
             }
       }
      else
        {
        $originalstring=str_replace($originalstring,$valueasreplacement[i]);
        }
       //any other stuff 
      return $str1;
   }
}

and in your code

<td><?php echo replace_str($fixture->date,array('T','S'),array('','')); ?></td>

note:avoid directly modifying the values of variables (i mean why the api might be adding that z and T in your date may be with some purpose so be sure to keep original values intact when you perform such replacements,just in case you need original value..:D)