echo (date('d-m-Y',strtotime("1997-02-27T00:00:00+08:00")));
The result of this is one day before. 26-02-1997
I have an API that brings time like the format above. How can I implement timezone to date function ?
echo (date('d-m-Y',strtotime("1997-02-27T00:00:00+08:00")));
The result of this is one day before. 26-02-1997
I have an API that brings time like the format above. How can I implement timezone to date function ?
You can change the default timezone with date_default_timezone_set(). The list of timezones for that is here.
For example:
date_default_timezone_set('Australia/Sydney');
echo (date('d-m-Y',strtotime("1997-02-27T00:00:00+08:00")));
My current timezone is 26-02-1997, this makes it Australian: 27-02-1997.
Open the php.ini file and set this code date.timezone = "US/Central"
to define definitely.
You can check if alright on section date using the command:
<?php phpinfo();