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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:00:11+00:00 2026-05-24T20:00:11+00:00

When getting the time via PHP script ( time() ), during Daylight Savings Time

  • 0

When getting the time via PHP script (time()), during Daylight Savings Time it seems to return a time value that is one hour off. Is there any way to get the correct time, accounting for Daylight Savings Time?

  • 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-24T20:00:14+00:00Added an answer on May 24, 2026 at 8:00 pm

    time() returns a Unix timestamp and a Unix timestamp is a fixed period of time: number of seconds since the Unix Epoch. It isn’t affected by time zones.

    Once you have the precise moment, you may want to calculate the local time in a given place:

    <?php
    
    $now = time();
    echo $now . PHP_EOL;
    
    date_default_timezone_set('Europe/Madrid');
    echo date('r', $now) . PHP_EOL;
    
    date_default_timezone_set('Asia/Tokyo');
    echo date('r', $now) . PHP_EOL;
    

    … will print different local dates for the same timestamp:

    1313683738
    Thu, 18 Aug 2011 18:08:58 +0200
    Fri, 19 Aug 2011 01:08:58 +0900
    

    The same reasoning applies for the opposite operation:

    <?php
    
    date_default_timezone_set('Europe/Madrid');
    $then = mktime(23, 55, 30, 12, 31, 2000);
    echo $then . PHP_EOL;
    
    date_default_timezone_set('Asia/Tokyo');
    $then = mktime(23, 55, 30, 12, 31, 2000);
    echo $then . PHP_EOL;
    

    … will print different timestamps:

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

Sidebar

Related Questions

I'm a long-time ActionScript 2 user, now getting started with ActionScript 3. The one
Windows has GetFileTime API which allows getting file time information by open file handle.
Can I get an object's name in run time (like getting an object's type
I'm getting this message each time I compile my project: RunIPhoneUnitTest.sh: line 92: 31389
I'm a long time hobbyist programmer interested in getting into web application development. I
I am just getting into ibatis with SqlMap for the first time and I
I'm just getting started working with foreign keys for the first time and I'm
I am getting this error but only very occasionally. 99.9% of the time it
I'm getting some strange, intermittent, data aborts (< 5% of the time) in some
Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the

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.