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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:33:32+00:00 2026-05-21T02:33:32+00:00

I want to make a system which displays time dependant on the timezone in

  • 0

I want to make a system which displays time dependant on the timezone in a particular country. E.g. a table in my database contains country names in one field, and in the column next to it, it will contain GMT-compared timezones like -0100 or -0200.

What I need to do on the webpage then is set current GMT time ($time), and then pull the information from the database and alter $time to be GMT -1 or GMT -2.

Could someone tell me what the easiest way to do this would be please?

Thanks for any help

Edit:

So far I have this code:

    <?php

$time = date("H:i:s", time());
echo $time;
echo "<br/><br/>";
$myDateTime = new DateTime($time, new DateTimeZone('GMT'));
$myDateTime->setTimezone(new DateTimeZone('Antarctica/South_Pole'));
echo $myDateTime->format('Y-m-d H:i');
?>

which seems to do the job, and I could enter into the database ‘Antarctica/South_Pole’ rather than the GMT-/+ time. Would this do the job OK in the long run?

Also, using this method, would Daylight saving times be worked out OK?

  • 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-21T02:33:33+00:00Added an answer on May 21, 2026 at 2:33 am

    Using the DateTimeZone is the correct way to go about it.

    If you provide it with zoneinfo keys (such as America/New_York, or Antarctica/South_Pole as in your example) Daylight Saving time WILL be factored into the result, which is not the case if you have a naive database with only the UTC offset stored.

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

Sidebar

Related Questions

i want to make a system call in my python code but the problem
I want to make a login system using ASP.NET (MVC). On the internet, I
I want to make a custom ASP.NET control that is a subclasse of System.Web.UI.WebControls.Calendar
I have an object of the type System.Drawing.Image and want to make every pixel
My search system has two main parts: index and search. I want to make
I Make a J2ME Application and I just want to print the system date
I want make a bash script which returns the position of an element from
I want make datetimepicker in my project. Using jquery how it is possible? I
I want make interactive application where user launches it and can do various task
Let's say I want make some of my sources publicly available via my blog

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.