I store articles in a mysql database with their corresponding timestamps.
I would like to format the timestamps using the date(), and display whether it’s AM or PM when the article is retrieved from the database. Any help will be highly appreciated.
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.
Assuming you are using MySQL, you need to use date_format():
This gives you a 12 hour formatted time (hh:mm:ss followed by AM or PM), anyway also have a look at the relvant bits of the MySQL Documentation