Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the data type for unix_timestamp (MySQL)?

Tags:

types

sql

mysql

What data type should I use for saving unix_timestamp value (MySQL)?

like image 416
jjz Avatar asked Nov 08 '10 16:11

jjz


People also ask

What is Unix_timestamp SQL?

UNIX_TIMESTAMP() :This function in MySQL helps to return a Unix timestamp. We can define a Unix timestamp as the number of seconds that have passed since '1970-01-01 00:00:00'UTC. Even if you pass the current date/time or another specified date/time, the function will return a Unix timestamp based on that.

What data type is epoch time?

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.

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.


2 Answers

the type is integer like :

int(11)  

is good for indexing and conditions like > < =

like image 187
Haim Evgi Avatar answered Sep 16 '22 13:09

Haim Evgi


You want to use the TIMESTAMP data type.
It's stored as an epoch value, but MySQL displays the value as 'YYYY-MM-DD HH:MM:SS'.

like image 24
OMG Ponies Avatar answered Sep 20 '22 13:09

OMG Ponies