geeky · php code

mysql date column type

i have to say that the decision to make the birthday column for members on the new board type DATE is a very good one. i never knew about all the magic mysql DATE type can do πŸ™‚

but i still love the simplicity of time arithmetic unix timestamp provides.

5 thoughts on “mysql date column type

  1. Wow, thanks for the link! I’ve been working with PHP and built-in dates in mySQL and I kept running into problems :ouch: I can’t wait to give this a try!

    1. actually you can do something like select UNIX_TIMESTAMP(date_column) and it returns the unix timestamp. tho i still don’t see a very convenient way with date type to figure something like how many days it’s from a certain date. in unixstamp, you can just do
      ($timerightnow - $dateinquestion) / 24 * 3600 = NUM OF DAYS

  2. What I don’t like about having unix timestamps in the database is that it is impossible to read for the human eye. Which means, that when browsing the database with phpMyAdmin it’s really difficult to actually look at the dates. That’s why I more often than not set the type as DATE. πŸ˜€

  3. I have started using mysql based dates, times, timestamps instead of doing work with PHP, and my work has became much easier. If you trying to decide if place unix timestamp in the database or mysql native, GO for mysql one, your life will be easier too :biggrin:

Leave a reply to Fallen Cancel reply