开发者

unix time in mysql

开发者 https://www.devze.com 2022-12-19 05:13 出处:网络
when they say \"we will use unix time\", does that mean i should create a column like this ? date DATE

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消