问题
I have a .dat file that represents a Table in a database and has a particular column for timestamp
values. Now the values are stored in the following way: -
978302039
I'm required to copy all the elements into another table, but I'm not sure if the column containing these values should be of int
or timestamp
. As far as I know, we store timestamp
values in the following format: -
1000:09:12 00:00:00
But these values stored here don't look anything like that. Is there any internal representation of timestamp
values?
回答1:
Per MySQL Documentation
MySQL recognizes
TIMESTAMP
values in these formats:As a number in either
YYYYMMDDHHMMSS
orYYMMDDHHMMSS
format, provided that the number makes sense as a date. For example, 19830905132800 and 830905132800 are interpreted as '1983-09-05 13:28:00'.
With that, the value you have posted looks like a invalid timestamp
to me.
回答2:
978302039
looks like a unix timestamp in seconds. You can convert it to MySQLs DATETIME with the FROM_UNIXTIME() function.
SELECT FROM_UNIXTIME(978302039)
will return something like
2000-12-31 22:33:59
The exact value depends on the timezone configuration of your server.
来源:https://stackoverflow.com/questions/39597630/what-is-the-internal-representation-of-timestamp-values-in-mysql