Demo - Input Dates and Times
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.input.min.js"></script>
<div class="container">
<h1>
InputDateTime
</h1>
<p>
The InputDateTime control unifies InputDate and InputTime
into a single control, saving some screen real-estate in
scenarios where you do want to edit the date and time
parts of a Date object.</p>
<p>
The InputDateTime control <b>format</b> property should be
set to a format such as "g", which displays both date and time.
It has two drop-down buttons, one for showing a calendar and
one for a list of times.</p>
<p>
The InputDateTime control extends the InputDate, so all
properties and events are available as usual. It adds a
group of properties to control the time-specific parameters
of the control:</p>
<ul>
<li>
<b>inputTime</b>: Gets a reference to the inner
InputTime control.</li>
<li>
<b>timeMin</b>, <b>timeMax</b>, <b>timeStep</b>:
Get or set the parameters used to populate the list
of times shown in the time drop-down.</li>
<li>
<b>timeFormat</b>: Gets or sets the format used to
show time values in the InputTime drop-down.</li>
</ul>
<p>
The <b>InputDate</b> and <b>InputTime</b> controls can be
used separately or together, to edit the date and time
information in a Javascript <b>Date</b> object.</p>
<p>
For example:</p>
<label for="theInputDateTime">InputDateTime: </label>
<input id="theInputDateTime">
<p>
The current date/time is: <b><span id="dateTime"></span></b>.
</p>
</div>
CSS
label {
width: 120px;
text-align: right;
}
.wj-dropdown {
margin-bottom: 12px;
}
body {
margin-bottom: 36px;
}
JavaScript
onload = function() {
// edit date and time using an InputDateTime
var theInputDateTime = new wijmo.input.InputDateTime('#theInputDateTime', {
valueChanged: function(s, e) {
showDateTime(s.value);
}
});
// initialize the date/time value
var dt = new Date();
dt.setHours(17, 30, 0);
theInputDateTime.value = dt;
// show changes
function showDateTime(value) {
var el = document.getElementById('dateTime');
el.textContent = wijmo.Globalize.format(value, 'F')
}
}