如何正确设置在PHP中使用日期('Y-m-d')时给出的时间?

When I set the timezone to my current location (eg: Nairobi GMT +3) And then ask for the time using date('Y-m-d'), I get an incorrect value for minutes. i.e if it`s 11:03 AM it shows 11:15 AM (so +12 minutes difference).

Below is the code used. Pretty basic. Gets the job done.

date_default_timezone_set("Africa/Nairobi"); 
//echo date_default_timezone_get(); 
echo date('H:i:s');

Also this time difference only occurs in my client`s server. In other test servers , it provides accurate time. i.e 11:03 AM will show 11:03 AM.

Am I required to change the timezone in php.ini as well?

EDIT:

  1. The project isn`t in localhost.
  2. The output of time before & after the timezone set is the same :/

Probably your system time is 12 minutes ahead. If you are under linux, try

ntpdate -s time.nist.gov

what's the output of date before you set the timezone?

What's the ouput of

print_r(get_defined_vars())

Likely the server system time is ahead 12 minutes