[thelist] UNIX Timestamp versus the DateTime Field

Andrew Clover and at doxdesk.com
Sat Apr 13 08:44:01 CDT 2002


Anthony Baratta <Anthony at Baratta.com> wrote:

> The consensus (consensi? ;-) of the people answering questions appears to
> be leaning towards using UNIX Timestamps. Am I the only one that thinks
> this is "wrong" or problematic?

Not necessarily Wrong per se, but it's not the usual approach.

If the application in question uses Unix timestamps internally for
everything it might be easier to put that in the database and avoid
a conversion step, which can otherwise lead to confusion as date
formats tend to differ between databases, and usually you will have
to compensate for local/GMT time. If you use a 64-bit integer field
you won't have to worry about the epoch problem, at least if the
rest of your app can use 64-bit arithmetic for timestamps.

But you had better be sure you're never going to need date-related
DBMS features if this is the approach you're going to take. Only
integer comparison will be available for your SELECTs.

Unless there was specific reasons why an integer timestamp would
be advantageous to this specific project, I'd go with a date field
by default.

--
Andrew Clover
mailto:and at doxdesk.com
http://and.doxdesk.com/



More information about the thelist mailing list