dadamssg Posted March 31, 2009 Share Posted March 31, 2009 will mysql recognize mktime()s as a datetime? as if i do $end = mktime($_POST['ehour'], $_POST['eminute'],0, $_POST['emonth'], $_POST['eday'], $_POST['eyear']); and then be able to insert $end into my db? Quote Link to comment https://forums.phpfreaks.com/topic/151974-mktime-in-db/ Share on other sites More sharing options...
revraz Posted March 31, 2009 Share Posted March 31, 2009 MySQL wouldn't be using MKTIME, that would be PHP storing it in your $end variable. So echo $end, that is would would be inserted into your DB. Quote Link to comment https://forums.phpfreaks.com/topic/151974-mktime-in-db/#findComment-798206 Share on other sites More sharing options...
corbin Posted March 31, 2009 Share Posted March 31, 2009 You can convert a unix time stamp to a DATETIME value with FROM_UNIXTIME. Quote Link to comment https://forums.phpfreaks.com/topic/151974-mktime-in-db/#findComment-798215 Share on other sites More sharing options...
dadamssg Posted April 1, 2009 Author Share Posted April 1, 2009 hmm alright...im having trouble with adding 12 when pm is selected for a time selection list..it works fine except when i enter 12am or 12pm...if i enter jan 1 2009 12:00 pm i will get jan 2 2009 12:00 AM and if i enter jan 1 2009 12pm ill get jan 1 2009 12AM heres my html <select name='ehour'> <option value=1>1 <option value=2>2 <option value=3>3 <option value=4>4 <option value=5>5 <option value=6>6 <option value=7>7 <option value=8>8 <option value=9>9 <option value=10>10 <option value=11>11 <option value=12>12 </select> <B>:</B> <select name='eminute'> <option value='00'>00 <option value='05'>05 <option value='10'>10 <option value='15'>15 <option value='20'>20 <option value='25'>25 <option value='30'>30 <option value='35'>35 <option value='40'>40 <option value='45'>45 <option value='50'>50 <option value='55'>55 </select> <input type='radio' name='eampm' value='am'>am    <input type='radio' name='eampm' value='pm' checked>pm"; and heres the php part im having trouble with if($_POST['sampm'] == "pm") { $shour = $_POST['shour'] + 12; $start = mktime($shour, $_POST['sminute'],0, $_POST['smonth'], $_POST['sday'], $_POST['syear']); } else { $start = mktime($_POST['shour'], $_POST['sminute'],0, $_POST['smonth'], $_POST['sday'], $_POST['syear']); } Quote Link to comment https://forums.phpfreaks.com/topic/151974-mktime-in-db/#findComment-798292 Share on other sites More sharing options...
fenway Posted April 2, 2009 Share Posted April 2, 2009 hmm alright...im having trouble with adding 12 when pm is selected for a time selection list..it works fine except when i enter 12am or 12pm...if i enter jan 1 2009 12:00 pm i will get jan 2 2009 12:00 AM and if i enter jan 1 2009 12pm ill get jan 1 2009 12AM That's a php logic issue. Quote Link to comment https://forums.phpfreaks.com/topic/151974-mktime-in-db/#findComment-799324 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.