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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:11:34+00:00 2026-05-27T09:11:34+00:00

I have a weird problem concerning mysql timezone. In my website config file i

  • 0

I have a weird problem concerning mysql timezone.

In my website config file i have this line which sets the timezone :

mysql_query("SET SESSION time_zone = '$offset';"); // Offset is properly calculated, no worries about that

The funny part is that if i add another line right after this like this :

$q = mysql_query("SELECT NOW() as now");
$row = mysql_fetch_array($row);
echo $row["now"];

After executing that code, the time is displayed correctly.

BUT, in some other queries i insert rows in tables that have a column named date that defaults to CURRENT_TIMESTAMP.

Rows are inserted like this:

INSERT INTO `sessions` (`user_id`) VALUES `1`

(The sessions table has a date column that defaults to CURRENT_TIMESTAMP)

But the value inserted in DB still points back to the timezone of the server :((

Any ideas how to work through this ?

  • 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-27T09:11:35+00:00Added an answer on May 27, 2026 at 9:11 am

    You have to understand that MySQL maintains multiple time zone settings:

    • System time zone (basically the time zone set in OS)
    • Server time zone (the time zone used by MySQL)
    • Client time zone (the session time zone used per connection)

    See http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html for details.

    Date/time values are stored in two different ways:

    • All unix timestamp based values are always stored in UTC. They are internally converted from and to Client time zone on the fly when they are stored and read. The same is true for NOW() and CURTIME() functions as they are timestamp based.
    • DATE, TIME and DATETIME columns (which store their values in a year-month-day hour-minute-second format) are NOT affected by time zone settings and are never converted.

    From the above it should become clear that the values that you see when you read from unix timestamp based columns are not necessarily what is really stored in the DB. They are converted using the server time zone and the client time zone. The result can be confusing if you do not understand the details of the mechanics.

    For a first test try to find out the current settings in each of your client programs by executing

    SELECT @@global.time_zone, @@session.time_zone;
    

    The global time zone will always be the same. But the session time zone can differ from client application to client application and will change the results of your read and write operations.

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

Sidebar

Related Questions

I have this weird problem when trying to INSERT a row into my mysql
I have this weird problem with setting up cookies with PHP. Everything worked fine
I have a weird problem, and I don't know if this is the default
I have this weird problem where my Google Maps API script doesn't work, no
I have really weird problem with colors in interface builder. I set a color
I have this weird problem whenever I roll my mouse over each of the
I have this weird problem. I have an icon in my C++ project's resource
I have a weird problem with routing. I have an existing website that I
I have a weird problem with my code as the compiler generates code which
I have come across a weird problem concerning composite keys and one-to-many relationship. I

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.