On Wednesday, April 24, 2002, at 11:37  AM, Jackson Miller wrote:

> When storing dates and times in databases is it better to store them as
> UNIX timestamps or in one of the SQL date/time types?
>
> I am working on an application that takes school attendance and has
> homework assignments, so I am doing a fair amount of date work.
> Currently I am storing everything as date time and referring to a day
> with the UNIX timestamp for  midnight of that day.  I am able to do
> everything I need to do with both formats, but I am wondering if there
> is a performance issue at hand.

As I recently discovered, it is much better to store them as a SQL 
date/time type, because your database will be better equipped to make 
complicated queries of the data if it is stored in the database's 
preferred data type.

The flexibility of functions such as MySQL's DATE_FORMAT() or 
UNIX_TIMESTAMP() functions, and PHP's date() function, let you 
manipulate these numbers in any way you prefer for display, once the 
database has performed its work.


Erik




----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to