Date picker values into string?

I found a script that is called Datepicker to have a calendar where a user can pick a date and time.
I want them to pick a date and start time and end time as well and this one looks good on a demo page.

But if I want to store the values that are entered into a string to save in my db, how would that be done?

<script>
    // initialize input widgets first
    $('#basicExample .time').timepicker({
        'showDuration': true,
        'timeFormat': 'H:i'
    });

    $('#basicExample .date').datepicker({
        'format': 'yyyy-mm-dd',
        'autoclose': true
    });
	
    // initialize datepair
    var basicExampleEl = document.getElementById('basicExample');
    var datepair = new Datepair(basicExampleEl);
</script>

I would like to store it in a string with the date and time. But I have no idea how to do this from the inputs I get.
They are supposed to be included in a form later.

What are you attaching the .time and .date classes to? The way I have always used datepicker is to use a form text input box, and then the value from the datepicker gets picked up by my $_POST array.

Example:

<form action="process-form.php" method="post">
    <input type="text" class="date" name="date" />
    <input type="submit" name="submit" value="Submit" />
</form>

and then set the datepicker in the javascript:

$(".date").datepicker();

I may have misunderstood your question, though.

Oh, sorry. This is the input I have.

<p id="basicExample">
    <input type="text" class="date start" />
    <input type="text" class="time start" /> to
    <input type="text" class="time end" />
    <input type="text" class="date end" />
</p>

The inputs need a name attribute, and labels.

Well… after your comments I could do it on my own. I just added a name to the form and it seems to work.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.