[PHP] Formatting a Time field

2006-03-23 Thread Todd Cary
I have a field, Start_Time, in a MySQL DB.  Since it is not a 
TimeStamp, I believe I cannot use date(), correct?


I would like to format 09:00:00 to 9:00 AM.

If I convert the 09:00:00 with the strtotime(), I get a couple of 
extra minutes added.


Suggestions are welcomed

Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting a Time field

2006-03-23 Thread Tom Rogers
Hi,

Friday, March 24, 2006, 9:51:48 AM, you wrote:
TC I have a field, Start_Time, in a MySQL DB.  Since it is not a 
TC TimeStamp, I believe I cannot use date(), correct?

TC I would like to format 09:00:00 to 9:00 AM.

TC If I convert the 09:00:00 with the strtotime(), I get a couple of 
TC extra minutes added.

TC Suggestions are welcomed

TC Todd


use gmdate() to do the formatting. in strtotime you should give a date something
like
$ftime = gmdate('h:i A',strtotime(2000-01-01 $Start_Time));

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting a Time field

2006-03-23 Thread Richard Lynch
On Thu, March 23, 2006 5:51 pm, Todd Cary wrote:
 I have a field, Start_Time, in a MySQL DB.  Since it is not a
 TimeStamp, I believe I cannot use date(), correct?

 I would like to format 09:00:00 to 9:00 AM.

 If I convert the 09:00:00 with the strtotime(), I get a couple of
 extra minutes added.

You may be able to convince MySQL to convert it with a function from
http://mysql.com (hint: search for convert) and that might give much
more satisfactory results.

You should also consider biting the bullet and converting the field to
a real 'Time' type.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php