tags:

views:

13

answers:

3

can I do this is a query?

+3  A: 

See the UNIX_TIMESTAMP() function.

Bill Karwin
A: 

use the UNIX_TIMESTAMP() function.

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_unix-timestamp

cam
+1  A: 

This can be done in MySQL by using UNIX_TIMESTAMP() or UNIX_TIMESTAMP(date).

If called with no argument, this returns a Unix timestamp (seconds since '1970-01-01 00:00:00' UTC) as an unsigned integer.

If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC.

mysql> SELECT UNIX_TIMESTAMP();
        -> 1196440210
mysql> SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19');
        -> 1196440219
dvanaria