JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css">
<p>Focus here: <input type="text" id="datepicker1"></p>
<p id="info"></p>
JavaScript
$(function() {
/* START jQuery date-time plugin */
$.datepicker._getTimeText = function (inst, h, m) {
h = h || inst.selectedHour || 0;
m = m || inst.selectedMinute || 0;
if (this._get(inst, 'clockType') == 12) {
return (h == 0 || h == 12 ? '12' : h >= 12 ? h - 12 : h)
+ ':' + (m < 10 ? '0' + m : m)
+ ' ' + (h < 12 ? 'AM' : 'PM');
} else return h + ':' + (m < 10 ? '0' + m : m);
};
var formatDate = $.datepicker.formatDate;
$.datepicker.formatDate = function (format, date, settings) {
var inst = $.datepicker._curInst;
var showTime = inst ? this._get(inst, 'showTime') : false;
if (showTime) {
date.setHours(inst.selectedHour || 0);
date.setMinutes(inst.selectedMinute || 0);
}
return formatDate.apply(this, arguments) + (showTime ? ' ' + this._getTimeText(inst) : '');
};
/* END jQuery date-time plugin */
$("#datepicker1, #datepicker2").datepicker({
beforeShow: function(input, inst) {
inst.dpDiv.css({marginTop: -input.offsetHeight + 'px', marginLeft: input.offsetWidth + 'px'});
},
showTime: true,
clockType: 12
});
window.setInterval(function () {
var formatted = $.datepicker.formatDate("mm/dd/yy", new Date());
/*
`formatted` should only contain '12:00 AM' while the datepicker is displayed
*/
$("#info").html(formatted);
}, 100);
});