Where does PHP get its timezone from?

Viewed 43

We are experiencing some strange inconsistencies with time functions on a PHP application that we have.

We have some code that writes entries to a database, and it logs the current date & time using:

$currentDate = Date("Y-m-d");
$currentTime = Date("H:i:s");

Left alone, these items will go into the database 4 hours ahead of the current timezone that we're in (we're in EST timezone).

Now of course, this is easy enough to correct by adding:

date_default_timezone_set("America/New_York");

The problem is - it wasn't long ago that we didn't have to add that to the PHP file. Whenever we would add entries to the database, they would get entered under the correct timezone.

So, we're trying to figure out where PHP might be pulling its default timezone from.

Is it pulling it from the server that the files are on?

Is it pulling it from the php.ini file?

Is it pulling it from the .htaccess file?

Or is it some combination, depending on a variety of factors?

Can anybody please shed some light on this?

0 Answers
Related