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 8886381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:32:43+00:00 2026-06-14T21:32:43+00:00

I’ve faced a really funny problem. my server timezone is set to America/New_York (as

  • 0

I’ve faced a really funny problem. my server timezone is set to America/New_York (as indicated in phpinfo() and return value of date_default_timezone_get()) and now it is 23:30 PM in New York but when use echo date(h:i) it shows me 7:30 AM , with 8 hours offset!

My server system time also shows 7:30 AM and default timezone is not set in php.ini

Thanks for your help

  • 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-14T21:32:44+00:00Added an answer on June 14, 2026 at 9:32 pm

    Sounds simple.

    Based on the comments to your question, fix the time on the server and PHP will report the correct time.

    If your server is set in America/New_York timezone and PHP is also set to America/New_York, that is, if the server offset matches PHP’s offset, PHP will just output the server’s time.

    It’s possible you were assuming that PHP’s date() function is getting the current time from a time server or something; This is not the case.

    Bonus

    After writing the last part of my answer, I felt like figuring out how get time from an NTP time server, e.g., time.apple.com

    <?php 
    
    function ntp_time($host) {
    
      // Create a socket and connect to NTP server
      $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
      socket_connect($socket, $host, 123);
    
      // Send request
      $msg = "\010" . str_repeat("\0", 47);
      socket_send($socket, $msg, strlen($msg), 0);
    
      // Receive response and close socket
      socket_recv($socket, $recv, 48, MSG_WAITALL);
      socket_close($socket);
    
      // Interpret response
      $data = unpack('N12', $recv);
      $timestamp = sprintf('%u', $data[9]);
    
      // NTP is number of seconds since 0000 UT on 1 January 1900
      // Unix time is seconds since 0000 UT on 1 January 1970
      $timestamp -= 2208988800; 
    
      return $timestamp;
    }
    
    // Get America/New_York time from time.apple.com
    date_default_timezone_set('America/New_York');
    echo date('Y-m-d H:i:s', ntp_time('time.apple.com'));
    //=> 2012-11-25 23:59:02
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have been unable to fix a problem with Java Unicode and encoding. The
I am currently running into a problem where an element is coming back from
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all

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.