0

As the timezone in my each php file is Europe/Berlin. My first question is that, Why its Europe/Berlin? Is it a standard? or just I have this timezone?

I also find this code in php.ini file

[Date]
date.timezone=Europe/Berlin

and I replace it with

[Date]
date.timezone=Asia/Karachi

But still timezone is Europe/berlin at the first line of my index.php

I managed to set the timezone in my php file by writing this code,

date_default_timezone_set ( "Asia/Karachi" ) ;  

But when the control goes on to another file then timezone automatically becomes europe/berlin and i have to write the above line in my each php file.

So, is there any way to set my timezone once and it remains the same throughout my application?

I have read the question, answers and comments on this, php compiles timezone Europe/Berlin like UTC

But not found any solution. I haven't found any other link on stackoverflow.

matiit
  • 7,969
  • 5
  • 41
  • 65
Farrukh Sarmad
  • 315
  • 2
  • 5
  • 24
  • 1
    Because Berlin is clearly the best city. – More seriously though, we don't know why your personal installation defaults to that value. Secondly, are you sure you have edited the correct php.ini file? That might be several… – deceze Oct 13 '17 at 13:48
  • Have you tried using phpinfo() to make sure that you are using the php.ini file that you think you are using? – Mark_1 Oct 13 '17 at 13:49
  • @deceze Karachi is aslo a well known city though, I have just one php.ini file at xampp/php/php.ini as I am using xampp server. Where can I find more php.ini files you termed as "several"? – Farrukh Sarmad Oct 13 '17 at 14:01
  • @Mark_1 I have tried phpinfo() in my different pages to check which timezone is selected before and after setting to my given timezone. Are you suggesting me to use it somehow in php.ini file? – Farrukh Sarmad Oct 13 '17 at 14:04
  • http://php.net/manual/en/function.phpinfo.php – Sean Konig Oct 13 '17 at 14:09
  • I have confirmed my php.ini file through phpinfo() mentioned as "Loaded Configuration File C:\xampp\php\php.ini". And I have edited this same file. @SeanKonig – Farrukh Sarmad Oct 13 '17 at 14:17
  • Maybe this will help - https://stackoverflow.com/questions/8762608/setting-default-timezone-does-not-work-despite-timezone-being-valid?rq=1 – Sean Konig Oct 13 '17 at 14:28

3 Answers3

1

you have to set timezone of your php server

Farrukh Sarmad
  • 315
  • 2
  • 5
  • 24
  • 1
    While this might be a valuable hint to solve the problem, a good answer also demonstrates the solution. Please [edit] to provide example code to show what you mean. Alternatively, consider writing this as a comment instead. – Toby Speight Jan 30 '18 at 10:47
1

Although you wrote it 3 years ago, I also came across this post with the same problem. I found a solution in another article (https://www.py4u.net/discuss/26014). Please read the 'Answer #5'.

There were two 'date.timezone' in 'php.ini'. It was overwritten with the timezone setting that follows. I deleted it and it worked fine.

Thanks for posting a great question!

junho jeon
  • 11
  • 1
0

Maybe php setting place another code that replace the date time function you can check in php.ini for me is on line 1969 or after [Session]. There is a code that replace the date timezone to Europe/Berlin

Ridho_W
  • 1
  • 2