Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

field type for unix timestamp

Tags:

sql

Whats the best field type to use for unix timestamps?

Will int(10) be enough for a while?

like image 714
Megaman Avatar asked Jan 03 '10 00:01

Megaman


People also ask

What data type is Unix timestamp?

The Unix time_t data type that represents a point in time is, on many platforms, a signed integer, traditionally of 32 bits (but see below), directly encoding the Unix time number as described in the preceding section. Being 32 bits means that it covers a range of about 136 years in total.

What is the datatype for timestamp?

The TIMESTAMP datatype is an extension of the DATE datatype. It stores year, month, day, hour, minute, and second values. It also stores fractional seconds, which are not stored by the DATE datatype.

Is Unix timestamp long or int?

Unix timestamps should be stored as long numbers; if they are store as Java int values, then this leads to a 2038 year problem. 32-bit variables cannot encode times after 03:14:07 UTC on 19 January 2038.

What data type is epoch?

In a computing context, an epoch is the date and time relative to which a computer's clock and timestamp values are determined. The epoch traditionally corresponds to 0 hours, 0 minutes, and 0 seconds (00:00:00) Coordinated Universal Time (UTC) on a specific date, which varies from system to system.


1 Answers

Unix time_t is either 32 bits wide, or 64. So, int(8) or binary(8) is sufficient, at least for the next 293 billion years.

like image 83
Michael Petrotta Avatar answered Sep 21 '22 00:09

Michael Petrotta