Friday, 5 August 2016

unix_timestamp() : Return timestamp in seconds since '1970-01-01 00:00:00'



UNIX_TIMESTAMP() return timestamp in seconds since '1970-01-01 00:00:00'. If you don't pass any datetime argument to this function, it takes current time.


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

mysql>
mysql> SELECT UNIX_TIMESTAMP("2016-06-22 09:03:56");
+---------------------------------------+
| UNIX_TIMESTAMP("2016-06-22 09:03:56") |
+---------------------------------------+
|                            1466566436 |
+---------------------------------------+
1 row in set (0.00 sec)







Previous                                                 Next                                                 Home

No comments:

Post a Comment