bobby317 Posted June 15, 2010 Share Posted June 15, 2010 Ok I am using the form below to collect some information to store in a Mysql database one which is the date. I need to know how to convert that date into a php timestamp to convert to mysql and insert into my data base. I will have a php calendar that will detect the dates from the database and insert the event onto the appropriate date on the calendar. I am working through this pretty well just can’t figure out how to take the date gathered by the html form into a php timestamp. Thanks for all help and please explain so I may learn. <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" /> <form name="addEvent" action="addevent.php" method="post"> <p> <label for="eventName">Event Name:</label> <span id="sprytextfield1"> <input type="text" name="eventName" maxlength="30" size="20" /> <span class="textfieldRequiredMsg">Please enter a event name.</span></span></p> <p> <label for="date">Date:</label> <select name="month" id="date"> <option>January</option> <option>February</option> <option>March</option> <option>April</option> <option>May</option> <option>June</option> <option>July</option> <option>August</option> <option>September</option> <option>October</option> <option>November</option> <option>December</option> </select> <select name="day" id="date"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> <select name="year" id="date"> <option>2010</option> <option>2011</option> <option>2012</option> <option>2013</option> <option>2014</option> <option>2015</option> <option>2016</option> <option>2017</option> <option>2018</option> <option>2019</option> </select> </p> <p> <label for="startTime">Start Time:</label> <span id="sprytextfield2"> <input type="text" name="startTime" maxlength="10" size="10" /> <span class="textfieldRequiredMsg">Please enter a start time.</span><span class="textfieldInvalidFormatMsg">Invalid format. 00:00</span></span> <select name="timeOfDay1" id="startTime"> <option>AM</option> <option>PM</option> </select> </p> <p> <label for="endTime">End Time:</label> <span id="sprytextfield3"> <input type="text" name="endTime" maxlength="10" size="10" /> <span class="textfieldRequiredMsg">Please enter a end time.</span><span class="textfieldInvalidFormatMsg">Invalid format. 00:00</span></span> <select name="timeOfDay2" id="endTime"> <option>AM</option> <option>PM</option> </select> </p> <p> <label for="description">Description:</label> <span id="sprytextarea1"> <textarea name="description" rows="5" cols="50"></textarea> <span class="textareaRequiredMsg">Please enter your description.</span></span></p> <p> <input type="submit" value="Add Event" /> <input type="hidden" name="submit" value="true" /> </form> <script type="text/javascript"> <!-- var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "time"); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "time"); var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1"); //--> </script> Quote Link to comment https://forums.phpfreaks.com/topic/204807-converting-date-entered-into-html-form-to-php-timestamp/ Share on other sites More sharing options...
Psycho Posted June 15, 2010 Share Posted June 15, 2010 //Option 1 $timestamp = strtotime("{$_POST['year']}-{$_POST['month']}-{$_POST['day']}"); //Option 2 $timestamp = mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']); http://php.net/manual/en/function.strtotime.php http://us.php.net/manual/en/function.mktime.php Quote Link to comment https://forums.phpfreaks.com/topic/204807-converting-date-entered-into-html-form-to-php-timestamp/#findComment-1072206 Share on other sites More sharing options...
bobby317 Posted June 15, 2010 Author Share Posted June 15, 2010 Got it thanks again for everthing Quote Link to comment https://forums.phpfreaks.com/topic/204807-converting-date-entered-into-html-form-to-php-timestamp/#findComment-1072464 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.