MySQL - convert MM / DD / YY to Unix timestamp

Is there a simple (single request) way to do this?

I am reading these values ​​from a column in a table, and I think the column itself is defined as a row (it doesn't help me, I'm afraid).

+4
source share
3 answers

Use UNIX_TIMESTAMP ;

 SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19'); 

Update:

 SELECT UNIX_TIMESTAMP(CAST(fieldName AS DATE)); 
+4
source
 SELECT '12/31/10', STR_TO_DATE('12/31/10', '%m/%d/%y'), UNIX_TIMESTAMP(STR_TO_DATE('12/31/10', '%m/%d/%y')) 

Both functions are described here: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

+1
source
 SELECT UNIX_TIMESTAMP(STR_TO_DATE('08/05/10','%m/%d/%y')); 
+1
source

All Articles