Reputation: 6251
I got date, stored in MySQL column like this: 09-11-2012
(format is DD/MM/YYYY
), but when I do:
SELECT UNIX_TIMESTAMP(t.date) FROM table t;
It does returns 0
for every single row.
How can I convert this format date to the unix timestamp? I would like to convert this date just like the PHP's strtotime
is doing it.
Upvotes: 0
Views: 330
Reputation: 263733
I guest t.date
is a string right? try converting it to DATE
first using STR_TO_DATE
SELECT UNIX_TIMESTAMP(STR_TO_DATE(t.date, '%d-%m-%Y'))
FROM table t;
Upvotes: 3