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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:24:07+00:00 2026-06-09T08:24:07+00:00

How to store time properly so that the timezone can be changed later with

  • 0

How to store time properly so that the timezone can be changed later with user defined timezones? How do you typically do this using the DateTime class?

For example:

You run a forum script.

Your server’s local time is US

User A is from EU

User B is from JP

User A posted and sees the time based on his local time in EU.

User B sees User A’s post on his local time in JP.

My question is what timezone should you store the time. And how do you typically do this using DateTime class?

  • 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-06-09T08:24:10+00:00Added an answer on June 9, 2026 at 8:24 am

    Save the time in UTC format, for stability and consistency.

    Each user should have his preference saved in the database, in the form of PHP’s known timezones.

    Then, when displaying, change the time to the correct time zone.

    $time = "13:37 2012-12-21";
    $datetime = new DateTime($time);
    $user_timezone = new DateTimeZone($user_timezone_from_the_database);
    $datetime->setTimezone($user_timezone);
    $datetime->format("H:i:s Y-m-d");
    

    Would yield the correct date/time for the user.

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

Sidebar

Related Questions

I was using : total_time=datetime.time(int(total_time_text.replace(h,).replace(m,).split( )[0]),int(total_time_text.replace(h,).replace(m,).split( )[1]),0) to store the time length. But when
Using MySQL should I store time data as an Int which would be the
How to store date and time in different variable from this type of date
We're working on developing user widgets that our members can embed on their websites
I mean to store strict UTC time in a DateTime variable and output it
I'm trying to store a value to keep score every time that I recreate
I know that Java EE's session object can store complex objects, like a connection
Is it possibile to store time per point with millisecond precision? Since Graphite is
When I need to store time/date information, how is it best to be stored
I need to store a time offset in a database column (for example, 12:25

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.