1.unix_timestamp
Converts a time into a timestamp. (date type data converted to timestamp form integer)
Time stamp of the current time without passing the time parameter
Mysql> select Unix_timestamp ();
+------------------+
| Unix_timestamp () |
+------------------+
| 1361586358 |
+------------------+
1 row in Set (0.01 sec)
Mysql> Select Unix_timestamp (' 2013-01-01 10:10:10 ');
+---------------------------------------+
| Unix_timestamp (' 2013-01-01 10:10:10 ') |
+---------------------------------------+
| 1357006210 |
+---------------------------------------+
1 row in Set (0.00 sec)
2.from_unixtime
Converts a timestamp form integer to a date type
Mysql> Select From_unixtime (1355272360);
+---------------------------+
| From_unixtime (1355272360) |
+---------------------------+
| 2012-12-12 08:32:40 |
+---------------------------+
1 row in Set (0.00 sec)
Of course, you can also specify the time format for the output:
Mysql> Select From_unixtime (1355272360, '%y%m%d ');
+------------------------------------+
| From_unixtime (1355272360, '%y%m%d ') |
+------------------------------------+
| 20121212 |
+------------------------------------+
3. Limitations on MySQL Timestamp
At present timestamp can be expressed in the range of 1970-2038.
The time it takes to get out of this range will overflow is null.
Mysql> Select From_unixtime (0);
+---------------------+
| From_unixtime (0) |
+---------------------+
| 1970-01-01 08:00:00 |
+---------------------+
Mysql> Select From_unixtime (2147483647);
+---------------------------+
| From_unixtime (2147483647) |
+---------------------------+
| 2038-01-19 11:14:07 |
+---------------------------+
1 row in Set (0.00 sec)
Unix_timestamp and From_unixtime functions in MySQL