2

!rant
what is better, and what do you prefer, storing time like "1471275311" or "2016-08-11 18:50:42"

Comments
  • 0
    Always datetime in SQL. You're missing out on a lot of great functions by using int.
  • 1
    UNIX time stamp every time buddy!
  • 1
    Depends where it's stored! Use a DATE or TIME type in an SQL database. Databases are good at date arithmetic on those.

    If it's just in your own program (in a variable or memory store say) use whatever makes most sense.
  • 0
    UNIX time stamp is always preferred. ⏱
  • 0
    @iranjith4 Not in a database please!
  • 0
    @spl0 any reasons ?
  • 1
    @iranjith4 If you need Unix time, just use Unix_timestamp(Column). Need to group dates by week? Week(Column). The list goes on. And datetime is human readable.
  • 1
    @iranjith4 You can manipulate dates easily within the database if they're stored as the correct type!
  • 0
    I prefer unix timestamp. Easier to compare and manipulate. And easy to convert to real date. No problems with different localtimes/timezones/dst and all that crap if the db is moved between systems.

    Unixtime is same in the whole world. universal time. (and if system is supposed to last part 2038, then use 64 bit unix time)
  • 0
    First one. So much easier to read. I can get minute, hour, day, year, etc right off the bat from the first one, but I have to locate those in the second one
  • 0
    @sebastian Store your database dates in UTC if you want!

    I'm guessing you're not a heavy SQL user!
  • 0
    Unix timestamp I think slightly faster
  • 0
    @grolofson at what? Telling me if the timestamp was on a Saturday?
    :)
  • 0
    Being very marginally more efficient if you load in millions of them at once.
Add Comment