unix time in mysql
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 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.
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.
Unix-Time is normally seconds from 01-01-1970...means integer.
精彩评论