I need your help with datetime coversion. Inside my database I have date of comments entered like this:
Datetime: 2012-05-08 14:44:53
How can I make it display something close to this
May 15, 2012 2:44PM
Thanks for your time and patience.
DATE_FORMAT() is the answer to your question. It has several formats of date on this link
SELECT DATE_FORMAT(NOW(), '%M %d, %Y %h:%i %p') as FormattedDate;
View The Output Here [SQLFiddle]
%M Month name (January..December)
%d Day of the month, numeric (00..31)
%Y Year, numeric, four digits
%h Hour (01..12)
%i Minutes, numeric (00..59)
%p AM or PM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With