DateTimePicker
DateTimePicker copied to clipboard
datepicker dont display
date picker not display and display create?is_embedded=0:168 Uncaught ReferenceError: $ is not defined in browser console
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.
everything is run smoothly. thank you
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
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"
});
});
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?
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);
}
});
});