Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

DateTime field defaults to current time after upgrade



Issue with the Date-Time Calendar after upgrading from PRPC 5.5 to Pega 7.1.7. In the earlier version, the time is defaulted to 12:00 AM but in Pega 7.1.7 it defaults to current time.

Error Messages

Not Applicable.

Steps to Reproduce

1). Configure Date with "DateTimeCalender" Control in PRPC 6.3 SP1.
2). Upgrade the application to Pega 7.1.7.
3). Observe that "DateTimeCalendar" control will be replaced with "DateTime" control.
4). Select any date from the popup. System captures current time instead of explicit time.

Root Cause

As identified, the issue with the deprecated control "DatetimeCalender" which is available in PRPC 6.3 SP1.
In Pega 7 series the control "DateTimeCalendar" is been updated to "DateTime" control which holds an extra features from earlier control (taking current time into consideration on select of date).


Type: Local-change

Local-change: Provided the below snnipet to the user to get the required functionality as per their business needs


    $(document).ready(function() {

    function getStaticTimeOnDateSlec() {

        try {
            var dateTimeControlsIDs = [""]; // Provide date time control span id's here
            for (var idx = 0; idx < dateTimeControlsIDs.length; idx++) {

                var iconSpanObj = document.getElementById(dateTimeControlsIDs[idx]);
                if (iconSpanObj) {
                    pega.util.Event.removeListener(iconSpanObj, 'click', setDefaultHoursAndMinutes);
                    pega.util.Event.addListener(iconSpanObj, 'click', setDefaultHoursAndMinutes);
        } catch (e) {}

    function setDefaultHoursAndMinutes(event) {
        var _element = pega.util.Event.getTarget(event);
        setTimeout(function() {
            if (_element && _element.parentNode) {
                var inputElem = pega.util.Dom.getFirstChild(_element.parentNode);
                if (inputElem && inputElem.value != "") {

            // To set Hours value by default    

            var hoursDropObj = document.getElementById("hourDrop");
            if (hoursDropObj) {
                var listLength = hoursDropObj.options.length;
                for (var i = 0; i < listLength; i++) {
                    if (hoursDropObj.options[i].value == 2) {
                        hoursDropObj.options[i].selected = true;
                        hoursDropObj.options[i].defaultSelected = true;

                // To set Minutes value by default            

                var minuteDropObj = document.getElementById("minuteDrop");
                listLength = minuteDropObj.options.length;
                for (var i = 0; i < listLength; i++) {
                    if (minuteDropObj.options[i].value == 0) {
                        minuteDropObj.options[i].selected = true;
                        minuteDropObj.options[i].defaultSelected = true;
                // To set AM & PM values

                var amPmDropObj = document.getElementById("amPmDrop");
                listLength = amPmDropObj.options.length;
                for (var i = 0; i < listLength; i++) {
                    if (amPmDropObj.options[i].value == "AM") {
                        amPmDropObj.options[i].selected = true;
                        amPmDropObj.options[i].defaultSelected = true;
        }, 100);

Special Instructions: If user enabled "Show 24 hour format" with application locale like "en_GB" or "en_US", the above code might not work. The above code works when "Show 24 hour format" is disabled.

Suggest Edit

Published July 2, 2016 - Updated October 8, 2020

Did you find this content helpful? Yes No

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us