Is there any way to convert string to UNIX timestamp in MySQL?
For example, I have the string 2011-12-21 02:20pm which needs to be in Unix timestamp format.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
UNIX_TIMESTAMP()does the trick:However, the
UNIX_TIMESTAMP()function only takes a standard MySQL formatted date. If you want to use the AM/PM notation, you will need to useSTR_TO_DATEfirst like this: