Jump to: navigation, search

Mysql UNIX TIMESTAMP

From w3cyberlearnings

Contents

MySQL UNIX_TIMESTAMP Function

This function returns an unsigned integer of a Unix timestamp in second since '1970-01-01 00:00:00' UTC when there is no argument. When use with date argument, it returns an unsigned integer value in second since '1970-01-01 00:00:00' UTC.

Syntax UNIX_TIMESTAMP

  • date (optional): a date value
UNIX_TIMESTAMP(date);

Example 1

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

Example 2

mysql> SELECT UNIX_TIMESTAMP('2012-05-22 02:00:00');
+---------------------------------------+
| UNIX_TIMESTAMP('2012-05-22 02:00:00') |
+---------------------------------------+
|                            1337670000 |
+---------------------------------------+
1 row in set (0.00 sec)

Related Links



Navigation
Web
SQL
MISC
References