tags:

views:

52

answers:

3

when they say "we will use unix time", does that mean i should create a column like this ?

date DATE

or

date TIME

or

date DATETIME

?

A: 

Unix-Time is normally seconds from 01-01-1970...means integer.

Bobby
so you mean it should be created like this ? "date int"something like that ?
sasori
@sasori yes, exactly, treat it as an unsigned int (32bit :p or else your software will work when others fail in 2038)
kb
@kb: No! Unix time is a SIGNED integer. You have to do this if you want to store dates before 1970. Hence the Year 2038 problem: http://en.wikipedia.org/wiki/Year_2038_problem
R. Bemrose
+1  A: 

UNIX time is expressed as an integer value - number of seconds since the epoch. You'd just want to use an int field for this, not any of the date variants.

AJ
+3  A: 

A unix time is just a number representing the nr of seconds since 1970. If you want to store that directly, use an INTEGER.

You're likely better off storing this as a DATETIME, as that will facilitate easier querying. Though when inserting data you might need to convert it using the from_unixtime function.

A DATE stores only the date, not the time(hour/min/secs) and a TIME stores only the time not the date so they're not suitable.

nos