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

The Archive Base Latest Questions

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

PHP seems to use a rather annoying method for setting the evnironment timezone, using

  • 0

PHP seems to use a rather annoying method for setting the evnironment timezone, using region names rather than the GMT offset. This makes having a timezone dropdown a huge pain, because it either has to be huge to accommodate all possible PHP timezone values, or I have to find a way to convert a GMT offset to a valid value to pass to PHP.

So, given a GMT offset, how might I set the timezone in PHP? For example, how might I convert the GMT offset value of ‘-8.0’ to a value that I could pass to date_timezone_set()?

  • 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. 2026-05-11T13:14:25+00:00Added an answer on May 11, 2026 at 1:14 pm

    Using a region name is the right way to describe a time zone. Using a GMT offset on its own is hugely ambiguous.

    This is reflected in your question – how should you convert a GMT offset of -8 into a time zone? Well, that depends on what ‘GMT -8’ really means. Does it mean ‘UTC -8 at every point in time’ or does it mean ‘UTC -8 during winter time, and UTC -7 in summer time’? If it’s the latter, when does winter start and end?

    I would hope that PHP accepted a well-known set of values for the ‘fixed’ (no DST) time zones, e.g. ‘Etc/GMT+3’ etc. But unless you really, really mean a fixed time zone, you’re better off finding out which region you’re actually talking about, because otherwise your calculations are almost guaranteed to be wrong at some point.

    I’ve been wrestling with time zones for most of the last year. They’re a pain – particularly when some zones change their rules for DST (like the US did a few years ago) or when some zones opt in and out of DST seemingly at will. Trying to reflect all of this in a single number is folly. If you’re only interested in a single instant in time, it might be okay – but at that point you might as well just store the UTC value in the first place. Otherwise, a name is the best approach. (It’s not necessarily plain sailing at that point, mind you. Even the names change over time…)

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

Sidebar

Ask A Question

Stats

  • Questions 74k
  • Answers 74k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Any particular reason you put the PK over both the… May 11, 2026 at 2:27 pm
  • added an answer BlobCache documentation and samples are on MSDN. May 11, 2026 at 2:27 pm
  • added an answer Updating doesn't work - you'd have to insert the new… May 11, 2026 at 2:27 pm

Related Questions

I am working on a few PHP projects that use MVC frameworks, and while
I recently started learning Python and I was rather surprised to find a 1000
We're not doing real web development. We get our HTMLs from our designers, and
In PHP 5.2 there was a nice security function added called input_filter, so instead

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.