It depends on the DBMS that you are using. MySQL has a lot more built in date/time functions than SQL Server 2000 for example, but do a little research on your system to see what functions there are. This will work with all of the common ones..
If you are using MySQL, you can do it with just a single sql command:
Code:
select date_format(db_column, '%h') as hr, date_format(db_column, '%i') as min, date_format(db_column, '%p') as symbol from table_name
If its not MySQL
SQL statement:
Code:
Select hour(db_column) as hr, minute(db_column) as mn from table
Symbol Logic:
Code:
$symbol = "am";
if ($hr >= 12)
$symbol = "pm";
Now you have all three parts to work with. Just be sure that it is of type datetime or time. Also note that some other MySQL functions have the ability to return hours > 24 if doing comparisons or other operations. This would change your logic here.
Hope this helps.
Jeff