MySQL Tutorial/Date Time Functions/UNIX TIMESTAMP

Материал из SQL эксперт
Перейти к: навигация, поиск

SELECT UNIX_TIMESTAMP("2005-00:00");

mysql>
mysql> SELECT UNIX_TIMESTAMP("2005-03-27 03:00:00");
+---------------------------------------+
| UNIX_TIMESTAMP("2005-03-27 03:00:00") |
+---------------------------------------+
|                            1111917600 |
+---------------------------------------+
1 row in set (0.02 sec)
mysql>


UNIX_TIMESTAMP(date) returns the value of the argument as seconds since "1970-00:00" UTC

mysql>
mysql> SELECT UNIX_TIMESTAMP("1997-10-04 22:23:00");
+---------------------------------------+
| UNIX_TIMESTAMP("1997-10-04 22:23:00") |
+---------------------------------------+
|                             876028980 |
+---------------------------------------+
1 row in set (0.00 sec)
mysql>


UNIX_TIMESTAMP() returns a Unix timestamp (seconds since "1970-00:00" UTC) as an unsigned integer.

mysql>
mysql> SELECT UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
|       1185158783 |
+------------------+
1 row in set (0.00 sec)
mysql>