Re: [PHP-DB] dates and updates recommendation?

2003-01-26 Thread Jason Wong
On Sunday 26 January 2003 17:02, Paul Chvostek wrote:

 So what's the best way to store a date?  I've always liked storing epoch
 seconds as INTs, and leaving the translation to/from a human-readable
 date up to the application, but aside from the relative unreadability of
 this, are there any significant disadvantages to this method, aside from
 the rollover problem in 2038?  (The S32b bug?)

 Would I be better off spending a few bytes extra per record and storing
 things as DATETIME rather than an INT?  If I'm looking at the possibily
 making the application more database-portable in the future, are there
 gotchas I should be aware of with any particular field types?

I think it really depends on where you think you would be doing most of your 
date manipulations. If most will be done within your SQL queries then use the 
native DBMS date formats (as a plus MySQL has loads of useful date 
functions). If your date stuff will mostly be done in PHP then use unix 
timestamps.

On the whole I would stick to a DBMS native date format because:

 - it's human readable
 - built-in date functions
 - not limited to post epoch dates

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
If Machiavelli were a hacker, he'd have worked for the CSSG.
-- Phil Lapsley
*/


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




RE: [PHP-DB] dates and updates recommendation?

2003-01-26 Thread John W. Holmes
[snip]
 Would I be better off spending a few bytes extra per record and
storing
 things as DATETIME rather than an INT?  If I'm looking at the
possibily
 making the application more database-portable in the future, are there
 gotchas I should be aware of with any particular field types?

This has been argued back and forth quite a few times on here. If you
want your application portable, use an INT column, store UNIX
timestamps, and have PHP do all of the conversion/comparisons for you.

If you're just going to be using MySQL, then I definitely recommend
using it's date/time format. MySQL has a wealth of date/time functions
that make it really easy to get exactly what you want out of the table.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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