0

I have a string time 2020-05-18T15:58:01Z. How can I convert it into Australia/Sydney time in the format Y-m-d H:i:s so that its a date or datetime object?

$str = '2020-05-18T15:58:01Z';
$converted = strtotime($str);
echo(converted)
Zoey Malkov
  • 776
  • 6
  • 16
  • 1
    Does this answer your question? [PHP date() with timezone?](https://stackoverflow.com/questions/20288789/php-date-with-timezone) – catcon Jul 29 '21 at 04:30
  • @catcon Not really, how would I pass in `$str` – Zoey Malkov Jul 29 '21 at 05:19
  • 2
    You can create a `DateTime` object with your `$str`, then change that object timezone to `Australia/Sydney`, see [this](http://sandbox.onlinephpfunctions.com/code/d9f9892ed91d9dab2e0afaefc96f92cd5e112d9b) – catcon Jul 29 '21 at 05:49

0 Answers0