arjay_comsci Posted September 1, 2009 Share Posted September 1, 2009 i have this date format 04:00 and I want to echo it to two drop down boxes, 04 for the first box and 00 for the second box by clicking the Edit button. The value 04:00 had been already display in the form page and I want it to be display on drop down boxes. my code is this.. <?php $_sql="SELECT day, daydesc, room, starttime, wsid, endtime, location, locationname, roomname FROM weeklyeventscheddesc WHERE weeklyeventscheddesc.weid=".@$_GET["weid"]; } $data = $vdb->SelectAll($_sql); foreach ($data as $s_row) { $wsid= $s_row['wsid']; $room=$s_row['room']; $day= $s_row['day']; $location= $s_row['location']; /* starttime==04:00 this would be the value */ ?> <tr> <td><?php echo $s_row['daydesc'] ." ". $s_row['starttime']. " ". "-". " ". $s_row['endtime']. " ". " ". "  ". "  ". $s_row['locationname']. "  ". "  ". $s_row['roomname'];?> <td align="right"><input type="submit" name="Edit" value="Edit" id="Edit2" onclick="SelectThisSched('EditSchedule','<?php echo $wsid; ?>','<?php echo $room;?>', '<?php echo $day;?>', '<?php echo $location;?>');ShowHideAdd('EditSchedule','block')" /></td> </td> </tr> <?php } ?> and this is the javascript code function SelectThisSched(div, wsid, room, day, location) { var x=0; var s; if (document.getElementById) { x = document.getElementById(div); if (x) x.style.display = 'block'; x = document.getElementById('wsid'); if (x) x.value = wsid; x = document.getElementById('room'); if (x) x.value = room; x = document.getElementById('day'); if (x) x.value = day; x = document.getElementById('location'); if (x) x.value = location; x = document.getElementById('eActve'); if (x) x.value = actve; } } Please help me Link to comment https://forums.phpfreaks.com/topic/172644-how-to-split-date-format/ Share on other sites More sharing options...
MadTechie Posted September 1, 2009 Share Posted September 1, 2009 I would recommend you have starttime as a timestamp and then do $hours = date("G",$s_row['starttime']); $minutes = date("i",$s_row['starttime']); however if you keep it as a string, you can split it like this list($hours,$minutes) = explode(":",$s_row['starttime']); EDIT: also this question suite the PHP Help section better (I'll move it) Link to comment https://forums.phpfreaks.com/topic/172644-how-to-split-date-format/#findComment-910069 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.