tqla Posted February 9, 2010 Share Posted February 9, 2010 hello, I know that I can format a MySQL field with the type DATE like this: date("F j, Y, g:i a"); But how do I format a MySQL field that has a type of TIME? Thanks. Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted February 9, 2010 Share Posted February 9, 2010 in mysql date_format(); you'll have to check to documentation to get all the options. in php $formatted_date=date("your date options here", $timestampfrommysql); Quote Link to comment Share on other sites More sharing options...
tqla Posted February 9, 2010 Author Share Posted February 9, 2010 So formatting a DATE field and a TIME field both use the date() function. Thanks! Quote Link to comment Share on other sites More sharing options...
tqla Posted February 9, 2010 Author Share Posted February 9, 2010 Actually this is not working. My eventTime mysql field is set to TIME and reads like this: 16:00:00 So I have done this: $eventTime = $row_event->eventTime; $eventTime = date("g:i a", $eventTime); and when I echo it it reads: 12:00 am What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted February 9, 2010 Share Posted February 9, 2010 I was thinking timestamp not time. you'll have to convert it to a unixtimestamp try $eventTime=date("g:i a", strtotime($eventTime)); Quote Link to comment Share on other sites More sharing options...
tqla Posted February 9, 2010 Author Share Posted February 9, 2010 Thanks! I was trying mktime when you answered and that almost worked. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.