0

why i have difference between timezone in ssh and php

$ TZ=Africa/Khartoum date

print : Mon Apr 30 13:40:41 CAT 2018

but in php

date_default_timezone_set('Africa/Khartoum');
echo date('D M d Y H:i:s');

print : Mon Apr 30 14:40:41 CAT 2018

so how can i fix this , and i know in ssh time is correct time , but in php its not correct ?

mrmelad
  • 1
  • 1
  • I'd start by setting the timezone in your php.ini instead of using the PHP function... – Jakub Lucký Apr 30 '18 at 12:04
  • PHP is probably executed as web-browser user not the owner of the files (so not as the ssh user). Different user, different locale and timezone. phpinfo() could help you. – Giacomo Catenazzi Apr 30 '18 at 12:07
  • thx all , but i need to show with two location time in php , and wana show correct time as ssh , so is there any way to get this time in ssh to php – mrmelad Apr 30 '18 at 12:39

0 Answers0