Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2013

    Datatype for date ?

    hey,I am a newbie learner,this might sound a stupid question but yes,what datatype to choose for data format.
    I googled it,but disappointed to get no answer,usually the date datatype ranges from 0001-01-01 through 9999-12-31,and it is in numeric form,
    in my contact form,I have a jquery datepicker,when user selects the date,the value displayed on the textbox is like this "March 13th, 2013" ,I am wondering what datatype to use.
    and for time,in the format "14:20" what datatype to use?

    the code of my form is ~

    <?php include 'process-form.php'; ?>

    <div class="wrapper clearfix">
    <div id="contact-wrapper" class="clearfix">
    <div class="form-wrapper clearfix">
    <div class="message">
    <?php echo !empty($error_list) ? $error_list : ''; ?>

    <form name="contact-form" id="contact-form" action="database.php" method="post">

    <div class="field">
    <label for="name">Name</label>
    <input type="text" id="name" name="name" autofocus required="required">

    <div class="field">
    <label for="email">Email</label>
    <input type="email" id="email" name="email">

    <div class="field">
    <label for="phone">Phone</label>
    <input type="text" id="phone" name="phone" required="required">

    <div class="field">
    <label for="time">Time</label>
    <input type="text" style="width: 70px;" id="timepicker.[1]" value="" />
    <script type="text/javascript">
    $(document).ready(function() {
    $('#timepicker\\.\\[1\\]').timepicker( {
    showAnim: 'blind'
    } );

    <div class="field">
    <label for="date">Date</label>
    <input id="datepick" />

    <div class="field">
    <label for="trip_type">Trip type</label>
    <select id="trip_type" name="trip_type" required="required">
    <option>Point to Point</option>
    <option>Round trip</option>

    <div class="field">
    <label for="pickup">Pickup location</label>
    <input type="text" id="pickup" name="pickup" required="required">

    <div class="field">
    <label for="destination">Destination</label>
    <input type="text" id="destination" name="destination" required="required">
    <div class="field">
    <label for="message">Message</label>
    <textarea id="message" name="message"></textarea>

    <div class="field submit">
    <input type="submit" value="Submit"/>
    For better view,I posted it on pastebin:
    1)the form

    These form script was taken from some site,I just modified it,it usually emails the contents,but I want all these form details to save on a database.
    please help me with this.
    I want the whole database query code which is to be run to make tables and fields for the name,address etc.
    and the php code ,the database.php code which will make it possible to save data on the db.

    Thanks a ton,please help me.
    If there is a website offering some GUI service or any other way to generate the MySQL code easily,please do post,and suggest any good website or free eBook by which I could learn MySQL.
    Last edited by akhandal96; 03-24-13 at 13:40.

  2. #2
    Join Date
    Mar 2013
    Breda, Netherlands
    There are no stupid questions, only stupid answers ;-)
    Just stored it as a datetime datatype, mysql has a STR_TO_DATE function which converts your input the proper format.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts