Tempus-dominus: Unable to set existing date and time while we edit, time is reset to 12 AM

Created on 17 May 2016  路  6Comments  路  Source: Eonasdan/tempus-dominus

The time portion is reset to 12 AM irrespective of what value is provided as input. Had an issue with 4.17.37 while initializing datetime to the current time, time was reset to 12 AM. I'm now using the 4.15.35. Issue with current time is resolved, but have the same issue on edit when we provide an input on datetime to initialize, time is reset to 12 AM but the date portion is rendered properly.

Code used to initialize...

$(".date-time-picker").datetimepicker({
            format: 'M/D/YYYY  h:mm A',
            locale: moment.locale('en')
});

html...

<div class="form-group">
            <label for="StartDate">Start Date<span class="required">*</span></label>
            <div class="date-time-picker input-group">
                <input class="form-control" data-val="true" 
                        data-val-required="The Start Date field is required"
                        id="start-date-time" name="StartDate" type="text" 
                         value="05/17/2016 2:46 AM">
                <span class="input-group-addon">
                    <span data-date-icon="icon-calendar" class="icon-calendar"></span>
                </span>
            </div>
        </div>

Most helpful comment

4.15.35 works with the current date time initialization. If you already have a value and if the control needs to be initialized to that value, then it fails. Date part is OK, time portion is reset to 12 AM always.

All 6 comments

I'm seeing this behaviour as well.

yep, I'm seeing the same...

I can replicate this issue as well. I am switching my project back to 4.15.35 where it works fine there.

4.15.35 works with the current date time initialization. If you already have a value and if the control needs to be initialized to that value, then it fails. Date part is OK, time portion is reset to 12 AM always.

i also encountered this issue and rolling back to 4.15.35 solved the issue for me.

Hi, the latest version, 4.17.47, doesn't have this error.

Was this page helpful?
0 / 5 - 0 ratings