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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:26:25+00:00 2026-05-15T23:26:25+00:00

I was reading over an article that shows some really good information and benchmarks

  • 0

I was reading over an article that shows some really good information and benchmarks about how well the three different MySQL date/time storage options perform.

MySQL DATETIME vs TIMESTAMP vs INT performance and benchmarking with MyISAM

While reading the article you start to get the idea that using ints are just a waste and you should instead go with MySQL Datetime or Timestamp column types.

However, towards the end of the article he does one more test not using MySQL functions and you suddenly see that straight INT’s are 2x as fast as the two MySQL options when searching by unix timestamps.

So it suddenly dawned on me – duh, what do PHP apps all use? time()! Almost every php application bases their logic off of the Unix Epoch. Which means that most queries for results in a certain time start off based on time() and then are converted to work with MySQL’s fields.

This leaves me with the following:

  1. Unix Timestamps stored as INT’s are
    faster, take less space, and work
    natively with PHP’s time() based
    calculations.

  2. MySQL Date types are more suited to
    operations and logic from the MySQL
    side.

  3. For the time being both Unix And
    MySQL Timestamps only work until
    2037 which means that you must use a
    datetime field for larger dates in
    the future.

  4. MySQL commands like date = NOW() can lag when
    using replication causing data inconsistencies.

So applying this to real life we see that answer
that these results given that most really DBA’s would use a better engine like PostgreSQL – is there arny

However, most apps that would be to the level of using DB logic would probably go with PostgreSQL. Which means that all the rest of us programmers only use MySQL for a storage tank for our data (you know it’s true) which makes keeping the fields as small, fast, UNIX INT’s seem like it is actually the best option.

So what do you guys think?

Are timestamps really more suited to PHP apps than the MySQL date fields?

  • 1 1 Answer
  • 3 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-15T23:26:26+00:00Added an answer on May 15, 2026 at 11:26 pm

    MySQL’s date format has no year 2038 problem.

    MySQL’s dates are reliable from the year 1000 to the year 9999, whereas Unix timestamps can screw up after 2038 or before 1902 unless everything in your system is 64-bit.

    If you’re using PHP, however, this can be moot: PHP uses unix timestamps for dates and times throughout most of its date and time functions and unless you are using a 64-bit build it will have the same limitation.

    You’d be using the field type that was intended for this purpose.

    If you care. Putting date into an INT field as a unix timestamp is not as self-describing; you can’t look at the data without converting it in the appropriate way. But that may make no difference to you.

    The flip side of this, given that you’re using PHP, is that once you get the time into PHP you’d have to convert it back to a Unix timestamp anyway to do anything useful with it, because to PHP, Unix timestamps are native.

    Edit:

    Back when I wrote this answer, I didn’t use PHP’s DateTime class. Using the DateTime class removes any need to use Unix timestamps, and removes the 32-/64-bit issues. Thanks to Charles’ comment below for pointing out a good way to use this.

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

Sidebar

Related Questions

Getters and Setters are bad Briefly reading over the above article I find that
I got a little curious after reading this /. article over hijacking HTTPS cookies.
I'm reading some MPEG Transport Stream protocol over UDP and it has some funky
I was reading about refactoring a large slow SQL Query over here , and
Over the past year I have heard alot about Velocity and NVelocity. Reading their
I was under the impression, after reading this article that it is better to
I was reading an article on Batch Processing in java over at JDJ http://java.sys-con.com/node/415321
I was reading today about researchers discovering that NVidia's Phys-X libraries use x87 FP
I was reading over http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html But I'm really not grasping how to ignore certain
I was reading over at the Android development website about using reflections. But I'm

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.