I can relate to wanting to have a date / time field in “human friendly” format. But doing so often means a lot of work will need to be done getting the values into “computer friendly” format to work with them and then changing them back to “human friendly” format. Can it be done? Sure. Is it efficient? No.
There are differences depending on the database used, but AFAIK, most have native date / time functions that work with date / time fields and come in quite handy.
Agreed @r937 I thought about that but I was hoping his needs were less than that. He needs datetime, then spend some time learning the sql parlance. I just KNEW someone was gonna call me out on it! haha! Good times!
Regarding the datetime thingy’s, because I use them so infrequently, I always dig back through 15 year old coding to ‘re-understand’ how to write a basic datetime query!
What I hate @Mittineague is seeing php time function outputs being stored in a database with a freakin varchar! But it’s not that difficult. While it’s a little more overhead, sticking with mysql datetime functions for this is king. Mysql has done an epic job with this over the years.
Thanks for the link. Jeez!
I swear, since the early 2000’s mysql’s online documentation has gone from technically lame to insane, to virtually needing a lawyer to read it, and even then it still conveys no real information to the newly adopted user.
‘Back in the day’, referring to mid-2000’s here, it was better suited to just ask google and look at other blogs referencing a particular select query.
I think the fork of MariaDB makes much sense and they are at least trying in the doc’s dept!
Datetime or Time?
It depends on the nature of the places that start and close.
For something like a shop or bar that opens and closes the same time every day, I would go for Time because it’s not tied to a specific date.
But if it’s something like an event or festival that only happens on a particular day or just a few days, then maybe go for Datetime.