MySQL

How to store date with HH,MM, AM/PM to MySQL

0 66

Store AM PM time string into TIME or DATETIME datatype in MySQL and retrieve with AM PM while display?

Save time as a regular 24 hour HH:MM:SS in the MySql time or datetime type. Do the formatting when executing query. Refer TIME_FORMAT() to reformat it into AM/PM format:

mysql> SELECT TIME_FORMAT('22:10:10', '%r');

mysql> 10:10:10 PM

About the author / 

codeadmin

Leave a reply

Your email address will not be published. Required fields are marked *

*