Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8713825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:26:05+00:00 2026-06-13T05:26:05+00:00

When I use PHP’s date() function on two different servers, I get two different

  • 0

When I use PHP’s date() function on two different servers, I get two different results, but both servers should be the same.

I checked the php.ini file on server #1, where the time is correct, and it looks as follows:

date/time support                   enabled
"Olson" Timezone Database Version   0.system
Timezone Database                   internal
Default timezone                    America/Chicago

Directive        Local Value        Master Value
---------------------------------------------------
date.timezone    America/Chicago    America/Chicago

I checked on server #2 and it looks as follows:

date/time support                   enabled
"Olson" Timezone Database Version   0.system
Timezone Database                   internal
Default timezone                    UTC

Directive        Local Value        Master Value
---------------------------------------------------
date.timezone    America/Chicago    America/Chicago

The only difference I see is the “Default timezone” value.

The date/time for both servers current display as:

Server #1: 10/23/2012 09:40:39
Server #2: 10/23/2012 14:40:39

I confirmed that both servers use the php.ini located within /etc and I also searched both web directories for any place the timezone might be overwritten:

grep -r "date_default_timezone_set" *

But in that regard, they both contain the same files with the same settings.

Is “Default timezone” what’s causing the 5h difference? If so, how do I correct it?

UPDATE

Loaded configuration files.

Server #2 contains two additional ini files:

/etc/php.d/snmp.ini
/etc/php.d/apc.ini

php -i results.

Server #1:

date/time support => enabled
"Olson" Timezone Database Version => 0.system
Timezone Database => internal
Default timezone => America/Chicago

Directive => Local Value => Master Value
date.timezone => America/Chicago => America/Chicago

Server #2:

date/time support => enabled
"Olson" Timezone Database Version => 0.system
Timezone Database => internal
Default timezone => America/Chicago

Directive => Local Value => Master Value
date.timezone => America/Chicago => America/Chicago

What’s interesting to note here is that for some reason the “Default timezone” does not match on server #2 when viewing it via php -i versus phpinfo() on a web page.

SOLUTION

The problem was with the CMS and its plugins. While server #1 and #2 had the same files and everything, it appears that plugins are not loaded in the same order on each server, which allowed the last plugin loaded to determine the timezone of my script.

The reason php -i and phpinfo differed is because after you use date_default_timezone_set(), it affects what phpinfo() will print.

The fix was the ensure that I’m in the timezone I needed to be in via date_default_timezone_set(). The reason that didn’t work for me before I posted this question was because I declared this prior to loading a few required files from the CMS, which probably set the timezone again in there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:26:06+00:00Added an answer on June 13, 2026 at 5:26 am

    date() relies on the date.timezone INI setting. Since one is Chicago (CT) and the other is UTC, that is your 5 hour difference.

    I believe as of PHP > 5.2 you should receive:

    PHP Warning: Unknown: It is not safe to rely on the system’s timezone
    settings. You are required to use the date.timezone setting or the
    date_default_timezone_set() function.

    I would encourage you to look at the new DateTime object or use UTC as advised by SDC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use php's date() function to print date on site. echo date('l, M j,
How to use php regular expression to get the position of date string in
I use php with ajax. <?php /* * Suppose, user has entered both correct
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I use PHP for programming contests (bad choice, I know. But it's the only
I use PHP for my project and need to display different pages for users
I want to use php mailer for sending multiple attachment in mail. But the
How can I use PHP closure function like function() use() on PHP 5.2 version
I use PHP mail() function to send emails from my website. No problems with
I use PHP zip function to extract files from a zip file $zip =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.