timmah1 Posted September 4, 2008 Share Posted September 4, 2008 I have a field in the database that uses 'time' How can I show 12 hour time instead of 24 hour time? I have a drop down menu with time, the value can stay at 24 hour, but what shows, i want that to show 12 hour time, how is this achieved? This is what i have now for($i=0;$i<=23;$i++){ echo "<option value=" . sprintf("%02d", $i) . ">" . sprintf("%02d", $i) . "</option>"; } The option value can stay at 24, but for visual, I need it to show 12 hour time to users. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/122663-time/ Share on other sites More sharing options...
tibberous Posted September 4, 2008 Share Posted September 4, 2008 $i % 12 <- for 12 hour floor($i / 12) <- for am / pm Link to comment https://forums.phpfreaks.com/topic/122663-time/#findComment-633378 Share on other sites More sharing options...
Ken2k7 Posted September 4, 2008 Share Posted September 4, 2008 Nevermind. Link to comment https://forums.phpfreaks.com/topic/122663-time/#findComment-633395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.