0

I'm using angular bootstrap timepicker. The problem I'm facing is that I have a mismatch between the view and the model. As you can see from the example, I chose 2015-05-07 but the model is a day behind.

<div dir="ltr" class="col-md-3 datePickerComponent">
                <div>{{payments.user.start_dt}}</div>
                    <span dir="rtl" class="datePickerLabel">
                     תאריך התחלה 
                    </span>&nbsp;
                    <p class="input-group">
                      <input ng-disabled="true" dir="rtl" ng-change="payments.GetPayments()" type="text" class="form-control" datepicker-popup="dd-MM-yyyy" ng-model="payments.user.start_dt" is-open="payments.opened_start"  />
                      <span class="input-group-btn">
                        <button type="button" class="btn btn-default" ng-click="payments.open_start($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                      </span>
                    </p>
                </div>

enter image description here

2 Answers 2

1

Apply the date filter to the value in your view

<div>{{payments.user.start_dt | date : format : timezone}}</div>

e.g.

<div>{{payments.user.start_dt | date : longDate}}</div>

see AngularJS Docs - Date Filter

Sign up to request clarification or add additional context in comments.

1 Comment

I just ran into the same problem. but why does this difference occur ?
0

I also faced this issue here Angular UI bootstrap date mismatch between model & datepicker

Adding the date filter to the view will just solve the problem of display. If you are sending it to a Rest API you would still get a day behind on the server.

To solve it, you will have to add this to your date picker.

ng-model-options="{timezone: 'UTC'}" 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.