Is there any way to convert string to timestamp in MySQL?
For example I have string 01-05-2016 10:22 am which needs to be fetch with order by desc .
is it possible to sort that ?
Is there any way to convert string to timestamp in MySQL?
For example I have string 01-05-2016 10:22 am which needs to be fetch with order by desc .
is it possible to sort that ?
UNIX_TIMESTAMP does the trick.
and
If you want to use the AM/PM notation, you will need to use STR_TO_DATE.
SELECT UNIX_TIMESTAMP(
STR_TO_DATE(' 2016-05-01 10:22 am', '%Y-%m-%d %h:%i%p')
);