1

I've xampp installed on my Local PC. But I've a Problem in my Timezone. PHP date shows my Date & Time 02/11/2018 05:26:18. but my PC Time is 02/11/2018 09:26:18. My Timezone is Asia/Karachi. I've Changed My Timezone in php.ini and My Timezone in php.ini Look like this

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Asia/Karachi"

I've also changed the right php.ini file according to phpinfo. I've restarted my Server many times but still getting the same timezone . My PHP version is 7.1.10

Shaida Muhammad
  • 1,428
  • 14
  • 25
  • Does `date_default_timezone_set("Asia/Karachi")` works in your script ? – Syscall Feb 11 '18 at 05:37
  • Yes it works @Syscall – Shaida Muhammad Feb 11 '18 at 05:47
  • Ok. Maybe you've not changed the right php.ini. Did you read https://stackoverflow.com/questions/32224547/setting-the-timezone-for-php-in-the-php-ini-file ? – Syscall Feb 11 '18 at 05:49
  • Yes i read it . and i've this path in phpinfo "C:\xampp\php\php.ini" and i changed the same file @Syscall – Shaida Muhammad Feb 11 '18 at 05:53
  • but it's still showing me the Europe/Berlin Timezone in phpinfo – Shaida Muhammad Feb 11 '18 at 05:54
  • Oh. there was a second date.timezone in that file and now that works fine . . . [Syslog] define_syslog_variables=Off [Session] define_syslog_variables=Off [Date] date.timezone=Asia/Karachi [MySQL] mysql.allow_local_infile=On mysql.allow_persistent=On mysql.cache_size=2000 mysql.max_persistent=-1 mysql.max_link=-1 – Shaida Muhammad Feb 11 '18 at 05:59
  • So, you could add an awser and mark it to accepted for futur users. Thanks. – Syscall Feb 11 '18 at 06:03
  • How ? i'm new to stackoverflow . . . give me an instruction link for that – Shaida Muhammad Feb 11 '18 at 06:11
  • Write the anwser of your question in the textbox below. Then check the green check on the left of the anwser after submitted it. Here is the link for how to accept : https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Syscall Feb 11 '18 at 06:51
  • There is a second `date.timezone` in php.ini
    In my case, it is in line 1972 under `[ffi]` block
    – José Mauricci Z. Sep 16 '20 at 00:12
  • This is the answer, or at least the other half. There are TWO locations to change: One under [date] and the other under [ffi]. Don't forget to restart the Apache server after saving the changes. Also, there can be two php.ini files. In my case Apache pointed to the incorrect one, as I needed to change the one under htdocs/dashboard. Cheers – JayJay123 Oct 17 '20 at 01:36

2 Answers2

1

As @Shaida Muhammad suggested in comments to the question, there seems to be a second date.timezone in php.ini for xampp. You can safely remove/comment the second date.timezone.

[Date]
date.timezone=Asia/Kolkata
A Yashwanth
  • 318
  • 4
  • 12
0

I have had the same issue, instead of going everywhere else i just clicked on Apache config button in xampp control panel and clicked on php.ini.

There is a second timezone line in that file go and search for it you will find your solution there.

[Syslog]
define_syslog_variables=Off
[Session]
define_syslog_variables=Off
[Date]
date.timezone=Asia/Karachi
[MySQL]
Usama Zahid
  • 11
  • 1
  • 1
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31628373) – treckstar May 02 '22 at 04:28