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

  • Home
  • SEARCH
  • 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 7025459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:58:40+00:00 2026-05-27T23:58:40+00:00

I ran this script: echo date_default_timezone_get().\n; echo —-\n; date_default_timezone_set(‘Asia/Kabul’); echo date_default_timezone_get().\n; echo —-\n; echo

  • 0

I ran this script:

echo date_default_timezone_get()."\n";
echo "----\n";

date_default_timezone_set('Asia/Kabul');
echo date_default_timezone_get()."\n";
echo "----\n";

echo time()."\n";
$dt = new DateTime;
echo $dt->format('U') . "\n";
echo "----\n";

date_default_timezone_set('UTC');
echo date_default_timezone_get()."\n";
echo "----\n";

echo time()."\n";
$dt = new DateTime;
echo $dt->format('U') . "\n";

and for all the 4 timestamp values, it says: 1325905766.

I read somewhere that new DateTime always sets UTC as timezone, whatever the timezone setting, so I get that, but what about time()?

A few seconds before, on a different server (probably not in Europe (ideone.com)), it returns 4 times: 1325905723.

That’s the same! (A few seconds diff obviously, but the same timezone.)

time() always and only returns UTC??? What’s going on??

  • 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-05-27T23:58:41+00:00Added an answer on May 27, 2026 at 11:58 pm

    Yes, they both use UTC. Specifically, both time() and the U format return the number of non-leap seconds elapsed since midnight UTC on January 1, 1970 (the “Unix epoch”). As the epoch is a fixed point whose definition is independent of the user’s timezone, and as the number of seconds since then is the same in all time zones (ignoring relativistic effects and whatnot), time() returns the same value regardless of time zone settings.

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

Sidebar

Related Questions

Ran across this line of code: FormsAuth = formsAuth ?? new FormsAuthenticationWrapper(); What do
This is a part of the code in a 'process.php' file: echo <script type='text/javascript'>
i just got my first ever stack overflow when I ran this script: var
I am working on an image upload script and ran into this problem. Using
I ran this script, but I keep getting the did not work message I
I ran this persons code. It worked as a main but when i put
How can you get 1 as an output from #2? #1 I ran this
I ran across this situation this afternoon, so I thought I'd ask what you
I ran across this and was wondering if someone could explain why this works
I ran into this today when unit testing a generic dictionary. System.Collections.Generic.Dictionary<int, string> actual,

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.