In MySQL, how can we represent the time value as an integer?


In MySQL, UNIX timestamp format is the way to represent time value as an integer. The integer value represented for the date value would be the number of seconds. The starting date for counting these number of seconds is ‘1970-01-01’.

mysql> SELECT UNIX_TIMESTAMP('2017-10-22 04:05:36')AS 'Total Number of Seconds';
+-------------------------+
| Total Number of Seconds |
+-------------------------+
|              1508625336 |
+-------------------------+
1 row in set (0.00 sec)

The UNIX_TIMESTAMP value is 10 digits long.

Updated on: 30-Jan-2020

482 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements