from datetime to timestamp mariadb code example

Example: mariadb convert date to timestamp

MariaDB [(none)]> SELECT UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
|       1269711082 |
+------------------+

MariaDB [(none)]> SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19');
+---------------------------------------+
| UNIX_TIMESTAMP('2007-11-30 10:30:19') |
+---------------------------------------+
|                            1196436619 |
+---------------------------------------+

MariaDB [(none)]> select unix_timestamp("2007-11-30 10:30:19.123456");
+----------------------------------------------+ 
| unix_timestamp("2007-11-30 10:30:19.123456") | 
+----------------------------------------------+ 
| 1196411419.123456 | 
+----------------------------------------------+

MariaDB [(none)]> SELECT FROM_UNIXTIME(UNIX_TIMESTAMP('2007-11-30 10:30:19'));
+------------------------------------------------------+
| FROM_UNIXTIME(UNIX_TIMESTAMP('2007-11-30 10:30:19')) |
+------------------------------------------------------+
| 2007-11-30 10:30:19                                  |
+------------------------------------------------------+

Tags:

Sql Example