Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the time in apache server so it matches the computer's time (PHP)?

Tags:

php

apache

In my particular case, both the server and the client are the same computer, I'm on localhost. When i echo out the date from the date() function, it displays a totally wrong value, a 11 hours earlier time. I also tried gmdate(), but it displays the date in AM not PM. Is there any way to change the apache server time, so everytime I get it in php, it displays the same as the time on my computer?

EDIT: Sorry for the late edit. I have already set the timezone in the php.ini but it still doesn't work. And I'm sure that my timezone is correct, since I got it from the manual and checked from phpinfo().

like image 853
menislici Avatar asked Dec 27 '11 19:12

menislici


People also ask

What is PHP default timezone?

The default timezone for PHP is UTC regardless of your server's timezone. This is the timezone used by all PHP date/time functions in your scripts.

How do I change the time zone on my website?

Method 1: Using Developer Tools to Change Chrome TimezoneOpen DevTools in Chrome -> Open the Console drawer. Click on the three-dotted menu -> Click on More tools -> Sensors. From the Sensors tab, set the location according to your preference and define the specific timezone.


1 Answers

I believe you are looking for: date_default_timezone_set ( string $timezone_identifier )

Link

You can also set this in your php.ini config.

like image 188
Andy Baird Avatar answered Oct 14 '22 11:10

Andy Baird