In my mysql database I have dates like this: 2011-01-06 09:39:114525
and I need to extraxt separately years, months, days, hours, minutes, seconds from it.
So I need to extract from above example:
2011
01
06
09
39
11
How can I do it ?
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.
In MySQL, just do
MONTH(date),YEAR(date), etc. In PHP, you can dodate('g', strtotime($datefromsql))to get, for example, the 12-hour format hour from the date.So in your above example, you could either do
or in PHP,