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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:50:32+00:00 2026-05-19T21:50:32+00:00

When building PHP applications I always end up having trouble trying to get everything

  • 0

When building PHP applications I always end up having trouble trying to get everything to play right with server times and timezones.

I generally have a simple timestamp-like field on most of my records that isn’t updated – just static for reference purposes. I use it to track when events happened, when users registered, when comments were created etc.

I have been trying to follow the best practices of using a Datetime field to store this value. The problem is that when using different servers they often have different timezones so the datetime’s don’t match up even close unless I add more code to offset the differences. This can also be a problem when using MySQL replication and NOW() queries since their is often a lag.

I’m wondering if I should go back to using ints since they don’t seem to care anything about timezones and only require the server clock is set. The downfall is that all those MySQL date/time functions (I never use) can’t be used which might be a problem in the future. The upside is that I can cut the storage space in half by moving back to 4byte ints instead of datetimes.

People also mention that ints will only work until 2037 – why is that a problem? Who expects to be using PHP + MySQL in 2037?

Is there anything I am missing? Is it better to store reference times in an agnostic way like Unix timestamps?

  • 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-19T21:50:33+00:00Added an answer on May 19, 2026 at 9:50 pm

    I use date/time fields in all my database work but store everything in GMT. Pretty much the first opportunity my code gets it converts something into GMT, and does all its internal math in gmt, etc. The only time I convert it back out of GMT into local time is when displaying to the user. PHP has unixtime() which is GMT, plus gmstrftime and gmdate, pretty much anything you’ll ever need.

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

Sidebar

Related Questions

I am building a PHP application in CodeIgniter. CodeIgniter sends all requests to the
I'm building a PHP application using the data mapper pattern to separate my DB
I'm building a PHP page with data sent from MySQL. Is it better to
I'm building a PHP site, but for now the only PHP I'm using is
As a look under the covers tutorial for myself I am building a PHP
When building some of my PHP apps, a lot of the functionality could be
I'm building a form with php/mysql. I've got a table with a list of
I'm building an XML document with PHP's SimpleXML extension, and I'm adding a token
I'm building a fairly simple PHP script that will need to send some emails
I'm building a small web app in PHP that stores some information in a

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.