Shaida Muhammad
Shaida Muhammad

Reputation: 1650

PHP my timezone is no setting up in PHP.ini File in xampp

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

Upvotes: 1

Views: 2427

Answers (3)

darioss
darioss

Reputation: 48

You need only set defaul time zone in your php file. Make this:

date_default_timezone_set('Asia/Karachi');

Is a good programming practice always specify the timezone for your projects in php script. So if you to change server, your code doesn't break.

date_default_timezone_set(*TIMEZONE OF YOUR PROJECT*);

If is important expose timezone for users, make with javascript

Upvotes: 0

Usama Zahid
Usama Zahid

Reputation: 11

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]

Upvotes: 0

A Yashwanth
A Yashwanth

Reputation: 402

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

Upvotes: 1

Related Questions