View Full Version : How to display time in 12 hour format?
I looked up on php.net the proper format for displaying date and time and it said to use %a to show am or pm.
I am using this command
time_format(`starttime`, '%h:%i ') as time
which works just fine until I add the %a, and then that column gives all nulls.
Why does this not work?
time_format(`starttime`, '%h:%i %a') as time
If %a is wrong, how do you display am and pm??
Thanks, e
thetestingsite
07-18-2008, 04:33 AM
Use %p. You can see more info at the following website:
http://www.eltcalendar.com/stuff/datemysqlphp.html
Hope this helps.
Great link. Thanks. Yes!! That worked.. thanks so much. I had wanted lowercase am/pm but that does not seem possible (none obviously didn't work). I'll settle for uppercase. :)
Actually, the uppercase AM and PM are too big now that I see them on the page. Any idea how to make them lowercase considering my variable ends up like below? Your link says that you use a small "a" to designate this in php but that didn't work in this command.
time_format(`starttime`, '%h:%i %p') as time
This is my display variable:
$event['starttime'] = $row2['time'];
Thanks, e
GarethMc
07-21-2008, 09:31 AM
How about...
(time_format(`starttime`, '%h:%i') . strtolower(time_format('starttime', ' %p'))) as time
Hope it helps :)
Actually that is what I ended up using, but then I decided not to use the time_format command because it caused unexpected results. So once it became php I was able to use:
$endtime = date('g:i a', strtotime($row['endtime']));
Thanks! e :)
GarethMc
07-21-2008, 09:55 AM
Actually that is what I ended up using, but then I decided not to use the time_format command because it caused unexpected results. So once it became php I was able to use:
$endtime = date('g:i a', strtotime($row['endtime']));
Thanks! e :)
Hehe .. well .. I always use the date() function myself ... would have been my next suggestion.. >.<
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.