DateTimePicker icon indicating copy to clipboard operation
DateTimePicker copied to clipboard

datepicker dont display

Open shahiran250890 opened this issue 7 years ago • 6 comments

date picker not display and display create?is_embedded=0:168 Uncaught ReferenceError: $ is not defined in browser console

shahiran250890 avatar Oct 20 '16 04:10 shahiran250890

DateTimePicker requires jQuery as a dependency, if jQuery is not included before DateTimePicker, this error may occur. If you are getting this error in any of the examples in demo folder, please specify the name of example file.

nehakadam avatar Oct 20 '16 16:10 nehakadam

everything is run smoothly. thank you

shahiran250890 avatar Oct 24 '16 02:10 shahiran250890

right now date format is "dd-MM-yyyy" so how can convert the date so it can be "yyyy-MM-dd" to be able to store into database

shahiran250890 avatar Oct 24 '16 06:10 shahiran250890

You can set date format as -

HTML -

<input type="text" data-field="date" data-format="yyyy-MM-dd" readonly>

OR

HTML Code -

<input type="text" data-field="date" readonly>

Javascript Code -

$(document).ready(function()
{
    $("#dtBox").DateTimePicker(
        {
        dateFormat: "yyyy-MM-dd"
    });
});

nehakadam avatar Oct 25 '16 17:10 nehakadam

it works but how can convert dd-MM-yyyy to database format yyyy-MM-dd so when user see the date picker they see date in structure?

shahiran250890 avatar Oct 28 '16 06:10 shahiran250890

Try following Code -

HTML Code -

<p>Date : </p>
<input type="text" data-field="date" data-format="dd-MM-yyyy" readonly>
<div id="dtBox"></div>

Javascript Code -

var inputDateString = "2016-10-22", outputDateString, dDateTime;

$(document).ready(function()
{
    $("#dtBox").DateTimePicker(
    {

        addEventHandlers: function()
        {
            oDTP = this;
            var inputDateStringComp = inputDateString.split("-");

            // Set Date 
            oDTP.settings.defaultDate = new Date(parseInt(inputDateStringComp[0]), parseInt(inputDateStringComp[1]) - 1, parseInt(inputDateStringComp[2]), 0, 0, 0, 0);
            dDateTime = new Date(oDTP.settings.defaultDate);

            oDTP.setDateTimeStringInInputField($("input"), oDTP.settings.defaultDate);
        },

        settingValueOfElement: function(sElemValue, dElemValue, oElem)
        {
            oDTP = this;

            if(oDTP.settings.mode === "date")
            {
                dDateTime = new Date(dElemValue.getFullYear(), dElemValue.getMonth(), dElemValue.getDate(), 0, 0, 0, 0);

                outputDateString = oDTP.getDateTimeStringInFormat("date", "yyyy-MM-dd");
            }

            console.log(dDateTime + " -- " + outputDateString);
        }
    });
});

nehakadam avatar Oct 30 '16 10:10 nehakadam