RE: [PHP] Convert 24hr to 12hr
RTFM http://www.mysql.com/doc/D/a/Date_and_time_functions.html select date_format(,"%r") from or select time_format(,"%r") from Look in the manual for more options... MUCH MORE :) Anyone know the difference between %h: 01-12 hour notation and %I: 01-12 hour notation ? Kind regards, Jerry > -Original Message- > From: Gary [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 06, 2002 3:44 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Convert 24hr to 12hr > > > Hello All, > Can someone please RTFM me so I can convert MySQL 24 hour > time to 12 > hour time. > TIA > gary > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > The information contained in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any form of disclosure, production, distribution or any action taken or refrained from in reliance on it, is prohibited and may be unlawful. Please notify the sender immediately. The content of the email is not legally binding unless confirmed by letter bearing two authorized signatures. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Convert 24hr to 12hr
On Tue, 2002-02-05 at 18:44, Gary wrote: > Hello All, > Can someone please RTFM me so I can convert MySQL 24 hour time to 12 > hour time. > TIA > gary Use MySQL's date_format() function with the %r specifier in your query: shanna% mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2401 to server version: 3.22.32-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> select date_format(now(), '%T'); +--+ | date_format(now(), '%T') | +--+ | 20:17:30 | +--+ 1 row in set (0.00 sec) mysql> select date_format(now(), '%r'); +--+ | date_format(now(), '%r') | +--+ | 08:17:39 PM | +--+ 1 row in set (0.00 sec) mysql> quit Bye shanna% This is documented at: http://www.mysql.com/doc/D/a/Date_and_time_functions.html Your query would then be something like the following, assuming a table named my_table and a date/time column named my_column: select date_format(my_column, '%r') from my_table Alternatively, select the date as a timestamp and feed it to strftime(): http://www.php.net/strftime Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php