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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:16:06+00:00 2026-05-16T14:16:06+00:00

So in my PHP code, I do timezone selection for the user, where I

  • 0

So in my PHP code, I do timezone selection for the user, where I have a table of timezones and their hour-shift values from GMT. I then use that to add to the DATETIME column values whenever the user picks his timezone in the SETTINGS.

So I have two functionalities: reading from DATETIME column in the database, and WRITING to the DATETIME column. Obviously, the first one I need to “add” the timezone difference before showing it to the user (using DATEADD() in SQL), while the second I need to “subtract” the timezone difference before store it in the database (also using DATEADD()). That way, all my stored timezones are in GMT, and viewed based on the selection of timezone of the user.

However, the Daylight Saving is the problem. What approach should I do (whether on SQL level OR PHP level), to solve this problem? Is using DATEADD() in SQL enough to take care of DAYLIGHT Savings? I have no clue. Please 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-05-16T14:16:07+00:00Added an answer on May 16, 2026 at 2:16 pm

    With SQL 2008 you have the new data time DATETIMEOFFSET which has time zone awareness as offset (as opposed to as timezone name). With this datatype you can get the UTC time of any value and then you can render it properly according to the user timezone (which is a transformation that belongs in the PHP code). The other option is to just store UTC always, in the old DATETIME data type. Whatever you do, the translation from user local to UTC and from UTC to user local belongs on the rendering in PHP, not to the SQL so DATEADD has not place in this code. The PHP DateTime has timezone support which is daylight savings aware.

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

Sidebar

Related Questions

I'm writing a php code where the user enter various details and then submits
I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);
I have some PHP code that inserts a date into a table: INSERT INTO
My PHP code is: $query=select company_name from company_names where cik=.$cik; Which on printing gives
I have the following PHP code, and for the life of me I can't
So I have a block of PHP code, and I simply wanted to have
System: Debian Lenny/Apache 2.2/php5.3.3 compiled from sources I'm strugglying with the date.timezone within php.ini.
Here is a test code: <?php ini_set('date.timezone', 'Europe/London'); $dt = new \DateTime('0000-00-00 00:00:00'); var_dump($dt);
I have the following PHP code on my local apache2 webserver on a Mac
Does php's date_default_timezone_set adjust to daylight saving? I have this code, and wonder if

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.