Welcome Guest, Not a member yet? Register   Sign In
Storing dates in mysql db: unix timestamps or datetime strings?
#1

[eluser]Bramme[/eluser]
Hi all

Another semantics question for you guys: storing dates in your database.

a) Do you store them as unix timestamps (using the php time() function) in an INT field and convert them to readable dates when you fetch them.
b) Or, do it the other way around: store them in a DATE(TIME) field and build them in php with date('Y-m-d').

At my firm, we use method b. I like the fact that you use the database fields as they are intented, but find it cumbersome to recalculate saved fields to unix timestamps when I need to calculate time differences or have to compare two dates for example.

I'd love to see some opinions on this.
#2

[eluser]Cristian Gilè[/eluser]
Hi Bramme,

there is a recent thread about this topic http://ellislab.com/forums/viewthread/177759/

Cristian Gilè
#3

[eluser]Bramme[/eluser]
Thanks for pointing it out, completely missed it.




Theme © iAndrew 2016 - Forum software by © MyBB