Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date Time Picker - Setting Opening Date and Time

I'm using this nifty little date and time picker [ http://trentrichardson.com/examples/timepicker/ ]. How can I set the date and time for when the picker opens?

like image 338
Roger Avatar asked Sep 23 '11 01:09

Roger


People also ask

How do I set the time on my datetime picker?

It Seems simple. $('#startdatetime-from'). datetimepicker({ language: 'en', format: 'yyyy-MM-dd hh:mm' });

How do I change date picker control?

Click the Date Picker Control in the Controls group. Click Properties in the Controls group. Click inside the Title text box and enter End Date:. In the Display The Date Like This list box, select the desired date format and then click OK.

How do I change date picker Format in Excel?

To change the way that the date is displayed, double-click the date picker, click the Data tab, and then click the Format button. Choose a display format in the Date Format dialog box.


2 Answers

If you're using this on a form, set it from a hidden input.

$(document).ready(function () {
        $("#Date").datetimepicker({
            ampm: true
        });

        var date = new Date(
            Date.parse(
                $('#DatePicker').val(),
                "mm/dd/yyyy hh:MM tt"
            )
        );
        $('#Date').datetimepicker('setDate', date);
    });

HTML Form:

<input type="hidden" id="DatePicker" />
<input type="text" id="DatePicker" value="fromyourdatabase" />
like image 116
John Zumbrum Avatar answered Sep 20 '22 01:09

John Zumbrum


Try this

$('#dtpkr').datetimepicker();
Then add

$('#dtpkr').datetimepicker('setDate', (new Date()));
This will give you the current date and time
like image 36
dinesh Avatar answered Sep 23 '22 01:09

dinesh