manxing
manxing

Reputation: 3335

unix time format in Mysql

Here I got a data like this: 1320609435.346877000, and I was told it was UNIX time which I do not understand. Shouldn't UNIX time look like an integer?

This data is stored in a txt as a column, if I want to insert this column into Mysql, which data type should I use and when I create a table, this default value should be assigned as NULL or ?

Many thanks!

Upvotes: 1

Views: 272

Answers (1)

Marco
Marco

Reputation: 57593

In MySql I always prefer using DATETIME type.
So you could use:

INSERT INTO your_table (your_col)
    SELECT FROM_UNIXTIME(your_num)

See reference here.
Unix time you posted (1320609435.346877000) is 2011-11-06 20:57:15.

Upvotes: 1

Related Questions