$(".e-datetimepicker").each(function () { $(this).ej2_instances[0].format = 'dd/MM/yy HH:mm'; });
<div>
<ejs-datetimepicker id="datetimepicker1"></ejs-datetimepicker>
<ejs-datetimepicker id="datetimepicker2"></ejs-datetimepicker>
<ejs-datetimepicker id="datetimepicker3"></ejs-datetimepicker>
<ejs-datetimepicker id="datetimepicker4"></ejs-datetimepicker>
<button id="btn" onclick="onButtonClick()">Click to change the Format</button>
</div> |
<script>
function onButtonClick() {
//Get all the DateTimePicker Elements in documents
var datePickerElements = document.querySelectorAll(".e-datetimepicker");
for (var i = 0; i < datePickerElements.length; i++) {
//Creating instance for DateTimePicker and set the format property
datePickerElements[i].ej2_instances[0].format = "dd/MM/yy HH:mm";
}
}
</script> |
$(document).ready(function () {
$(".e-datetimepicker").each(function () {
$(this)[0].ej2_instances[0].format = 'dd/MM/yy HH:mm';
});
}); |
<ejs-datetimepicker id="datetimepicker1" format="@ViewBag.format"></ejs-datetimepicker>
<ejs-datetimepicker id="datetimepicker2" format="@ViewBag.format"></ejs-datetimepicker>
<ejs-datetimepicker id="datetimepicker3" format="@ViewBag.format"></ejs-datetimepicker>
<ejs-datetimepicker id="datetimepicker4" format="@ViewBag.format"></ejs-datetimepicker> |
public IActionResult Index()
{
ViewBag.format = "dd/MM/yy HH:mm";
return View();
} |