Jump to content

mktime() in db


dadamssg

Recommended Posts

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 &nbsp&nbsp&nbsp<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']);
}

Link to comment
https://forums.phpfreaks.com/topic/151974-mktime-in-db/#findComment-798292
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/151974-mktime-in-db/#findComment-799324
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.